You are on page 1of 14

Parameters can be passed between forms using:

1) CALL_FORM 2) NEW_FORM 3) OPEN_FORM

Parameters can also be used to pass parameter to other Oracle products such as Oracle REPORTS

4) Run_Report_Object()
HOW TO PASS PARAMETER WITH SINGLE QUOTE FROM FORMS TO REPORTS

And

from one form to another form using a

5) menu item instead of a regular push button.

To do thi !ou c"n u e#


$) The %e&"u't P"r"(eter Li t Each form includes a built-in parameter List named Default. The Default parameter List contains all of the form parameters that were defined in the form at design time. or e!ample" if #ou define parameters p$" p%" and p& in orm ' at design time" the# are automaticall# included in the Default parameter List for orm '. The Default parameter List can be passed to a called form b# including it in the argument List of the OPE() OR*" +'LL) OR*" or (E,) OR* built-in procedures.
%ECLARE the_Li t PARAML)*T#+ ,et_P"r"(eter_Li t(-de&"u't-). /E,)N Open_For((-&or(_/-0ACT)1ATE0 NO_*E**)ON0-de&"u't-). EN%.

To create a parameter follow the step

$- .n the Ob/ect (a0igator" select the Parameters node and choose ('1.2'TOR-3+RE'TE. %- 4ring up the properties of the parameter and set the properties as needed. or e!ample" Set the datat#pe" default 0alue" and name of the parameter. &- To access the 0alue of the parameter" add the reser0ed word P'R'*ETER as a prefi! to the parameter name. .f #ou need to assign a 0alue to a parameter" use a regular assignment statement such as: te(p_2"r #+ #p"r"(eter32"ri"b. -- assigns the 0alue of the parameter to test)0ar #p"r"(eter31"ri"b #+ -2"'ue-. -- assigns a 0alue 50alue5 to the parameter ,hene0er #ou create a regular parameter" it is actuall# added to a default parameter list. 'll parameters that #ou define in the Ob/ect (a0igator belong to the default parameter list. 6ou can also pass the default parameter list to another form if #ou need. or e!ample: W4EN5/6TTON5PRE**E%
/E,)N CALL_FORM(-te t-0 NO_4)%E0 %O_REPLACE0 NO_76ER8_ONL80 -de&"u't-). EN%.

,hen passing the default parameter list as well as an# other parameter list" ma7e sure that e0er# parameter e!ists with the same name in the called form. 2) O9n p"r"(eter 'i t

6ou can also create #our own parameter list programmaticall# and pass it as an argument in a +'LL) OR* or OPE() OR* or Report 6ou can use the following built-in subprograms to create and manipulate a parameter List:
ADD_PARAMETER CREATE_PARAMETER_LIST DELETE_PARAMETER DESTROY_PARAMETER_LIST GET_PARAMETER_ATTR GET_PARAMETER_LIST SET_PARAMETER_ATTR

Tip: 8eep in mind the following when #ou create parameter Lists:

+RE'TE)P'R'*ETER)L.ST is a function whose return 0alue is the .D of the List being created. 6ou must assign the .D to a 0ariable that #ou declared as t#pe P'R'*L.ST 9an Oracle orms data t#pe-. ' call to +RE'TE)P'R'*ETER)L.ST creates a parameter List that does not #et contain an# parameters. To add parameters to the List" e!ecute the 'DD)P'R'*ETER procedure. 2ET)P'R'*ETER)'TTR and SET)P'R'*ETER)'TTR can be used to get and set the t#pe and 0alue of a parameter that has been added to a parameter List with the 'DD)P'R'*ETER built-in. Do not use these built-ins to get or set the 0alue of a form parameter that was defined at design time: instead" refer to the parameter using bind 0ariable s#nta! or indirect reference. 2ET)P'R'*ETER)L.ST is a function that returns the ParamList .D of an indicated parameter List" similar to the .(D-; functions a0ailable for other ob/ect t#pes.

The following e!ample creates a parameter List" adds two parameters to it" and then passes the List to a form b# wa# of the +'LL) OR* procedure:
:; ;; %ec'"re " 2"ri"b'e o& t!pe P"r"(Li t to tore ;; the p"r"(eter Li t )% ;: %ECLARE Li t_id P"r"(Li t. /E,)N :; ;; Cre"te " p"r"(eter Li t n"(ed <input_p"r"( < ;: Li t_id #+ Cre"te_P"r"(eter_Li t(-input_p"r"( -). :; ;; Add t9o p"r"(eter to the Li t to p" 2"'ue &or e"ch

One wa# to use a parameter list is to pass the 0alue of a te!t item that is used as a search criterion when calling another form. 'nother e!ample is to pass a 0alue to a report parameter that is used in the ,<ERE clause to retrie0e onl# certain rows. Suppose #ou need to pass the department number from one form 9department- to another form 9emplo#ee-: #ou use the department number to =uer# all emplo#ees wor7ing in that department in the emplo#ee form.

6ou can e!ecute the following code from a ,hen-4utton-Pressed trigger or e0en from a menu item:
%ECLARE Li t_id P"r"(Li t. /E,)N Li t_id#+ ,ET_PARAMETER_L)*T(-input_p"r"( -). )F NOT )%_N6LL(p"r"(_'i t_id) T4EN %E*TRO8_PARAMETER_L)*T('i t_id). EN% )F. Li t_id #+ Cre"te_P"r"(eter_Li t(-input_p"r"( -). A%%_PARAMETER('i t_id0 -e(p_=uer!-0 TE>T_PARAMETER0 #deptno). CALL_FORM(-e(p'o!ee-0 NO_4)%E0 %O_REPLACE0 NO_76ER8_ONL80 'i t_id). EN%.

1) 6ou must declare an ob/ect of t#pe ParamList

%- >se the 2ET)P'R'*ETER)L.ST built-in to find out if the parameter alread# e!ists. .f it e!ists" destro# it and recreate it. 6ou can use the DESTRO6)P'R'*ETER)L.ST built-in to delete a parameter list. &- 6ou can then add one or more parameters to the parameter list. The 'DD)P'R'*ETER re=uires the following arguments: -- The parameter list id" or parameter name -- The name of the parameter being created -- The parameter t#pe -- The parameter 0alue .n the e!ample abo0e" 5emp)=uer#5 is the name of the parameter" TE?T)P'R'*ETER is the parameter t#pe" and :deptno is the 0alue of the parameter. : emp)=uer# gets the 0alue from a te!t item called deptno. *ost of the parameters that #ou add are of the t#pe TE?T)P'R'*ETER" unless #ou tr# to pass a record group. Record group parameters must be defined as D'T')P'R'*ETER instead of TE?T)P'R'*ETER. To access the 0alue of a parameter in a called form" #ou must create the following triggers in the emplo#ee form:
1) W4EN5NEW5FORM5)N*TANCE "t the &or( 'e2e' 2) PRE576ER8 tri??er "t the b'oc@ 'e2e' Or 3) in " W4EN5NEW5FORM5)N*TANCE "t the &or( 'e2e' a. %e&"u't_9here b. one_ti(e_9here

.n addition" create a parameter with the same name as the parameter that #ou are passing in the parameter list :emp)=uer#. The application returns an error message that the parameter does not e!ist. The following is an e!ample of two triggers needed to do a =uer# based on the 0alue passed in the parameter list when the form 5emplo#ee5 is called: W4EN5NEW5FORM5)N*TANCE in called form at the form le0el
/E,)N E>EC6TE_76ER8. EN%.

PRE576ER8 in called form at the bloc7 le0el @; .f this is a called form" then" set up the search criteria based @; @; on the parameter emp)=uer# passed in the parameter list ;@
/E,)N #deptno #+ #p"r"(eter3e(p_=uer!. EN%.

W4EN5NEW5FORM5)N*TANCE with %e&"u't_9here 9or one_ti(e_9here- in called form at the form le0el
/E,)N )F #PARAMETER3 EMP_76ER8 i nu'' T4EN Enter_=uer!. EL*E *et_/'oc@_Propert!(-EMP-0%EFA6LT_W4ERE0 A %EPTNO + -BB#PARAMETER3EMP_76ER8). - AN% ANNO + -BB#PARAMETER3ANNO). eCecute_=uer!. end i&. EN%.

----4o9 to p" p"r"(eter &ro( one &or( to "nother &or( u in? " (enu ite( in te"d o& " re?u'"r pu h button3 TO P'SS P'R'*ETERS RO* OR*$ TO OR*% >S.(2 T<E *E(> .TE* $- +reate form$ e.g. based on !!! table. ,e will pass RE2)A>ER6 as the parameter %- +reate form% with a button. $- +reate a parameter under the ob/ect na0igator of form%. Let us name that parameter Bparam$B and ma7e the datat#pe B+harB in order to match RE2)A>ER6 datat#pe. C- +reate a menu using menudefs.mmb and name it e.g. m#menu D- +reate a menu item and name it Bcallform%B. E- >nder the propert# of the menu item Bcallform%B" bring the pl@s=l editor b# clic7ing on the B*enu .tem +odeB. T#pe the following code:
DECLARE param_list_id ParamList; REG_QUERY &EG'( ') REG_QUERY '* (+, (ULL ,HE( param_list_id "# GE,_PARA%E,ER_L'*, $,D+CU%E(,+$); ') (+, 'D_(ULL param_list_id) ,HE( DE*,R+Y_PARA%E,ER_L'*, $,D+CU%E(,+$); E(D '); param_list_id "# CREA,E_PARA%E,ER_L'*, $,D+CU%E(,+$); ADD_PARA%E,ER param_list_id- $REG_QUERY$- ,E.,_PARA%E,ER- REG_QUERY; VARCHAR2 5!) "# $%iller$;

from form$ to form%.

CALL_)+R% /01rm22-H'DE-D+_REPLACE-(+_QUERY_+(LY-*HARE_L'&RARY_DA,A-param_list_id); DE*,R+Y_PARA%E,ER_L'*, param_list_id); E(D '); E(D;

F- Sa0e the menu and compile it to create the mm!. G- Open the properties of the form le0el of form$ in order to assign the menu. >nder B*enu *oduleB" t#pe #our menu that #ou ha0e /ust modified Bm#menuB. H- >nder form%" create ,<E(-(E,- OR*-.(ST'(+E trigger with the following code:
&EG'( %E**AGE REG_QUERY); %E**AGE /2); E(D;

$I- Sa0e form% and compile it to create the fm!. $$- 2o bac7 to #our form$ and run it or instance" we would li7e to pass B*illerB as our parameter . RE2)A>ER6 from form$ to form%. $%- 2o to the menu item Bcallform%B in form$ and clic7 on that menu item in order to pass RE2)A>ER6 parameter e.g. B*illerB. ,hen #ou get form%" that will displa# the parameter that was passed from form$.

3) To C"'' Report 9ith " P"r"(eter For( <ow to 'ccess the 1alue of a Parameter in a report 9run_report_object() )
%ECLARE id_p' P"r"(Li t #+ N6LL. 2_repid REPORT_O/DECT. p"r"(_'i t_n"(e 1ARC4AR2(3E) #+ -p"r"_'i t"-. 2_rep 1ARC4AR2($EE). NREPORT M8W4ERE )NTE*TA_RP /E,)N 2_repid #+ &ind_report_object(NREPORT ). )d_p' #+ ,ET_PARAMETER_L)*T(p"r"(_'i t_n"(e). )F NOT )%_N6LL()d_p') T4EN %E*TRO8_PARAMETER_L)*T()d_p'). EN% )F. id_PL #+ CREATE_PARAMETER_L)*T(p"r"(_'i t_n"(e). 55 A%%_PARAMETER()%_PL0 -PARAMFORM-0 TE>T_PARAMETER0 -NO-). A%%_PARAMETER()%_PL0 -M8W4ERE-0 TE>T_PARAMETER0 M8W4ERE). A%%_PARAMETER()%_PL0 -)NTE*TA_RP-0 TE>T_PARAMETER0 )NTE*TA_RP). 1ARC4AR2(3E) #+ A(!reportF. 1ARC4AR2(3EE) #+ AF. 1ARC4AR2(3EE) #+ AF.

1_REP #+ run_report_object(2_repid0id_PL).

.n addition" create a parameters with the same name as the parameter that #ou are passing in the parameter list: M8W4ERE "nd )NTE*TA_RP . .n Report builder

Open up the Propert# .nspector of user parameter *6,<ERE and specif# the following:

(ame:

*6,<ERE

Datat#pe: +<'R ,idth: &II .nitial 0alue: '(D DEPT(O J K$IL 9.t can be an# 0alid 0alueSame for user parameter .(TEST')RP

<O, TO P'SS P'R'*ETER ,.T< S.(2LE A>OTE RO* OR*S TO REPORTS


<ow do #ou pass a parameter that contains single =uotes from Oracle orms to Oracle ReportsM E!ample ------<ow do #ou store the parameter 5test5" not test" in the databaseM <ence" in order for the report to wor7" the parameter must appear in the Parameter orm as 5test5.

>se sets of & single =uotes around the string literal. E!ample ------555test555 This appears as 5test5 in the Parameter orm.
---OR'-HIF or OR'-$%GI% when using =uote in the parameter
' report has to be used in web application. .t has a parameter that includes =uote signs li7e this : 50alue$5"50alue%5"..."50alue(5 ollowing problems occurred running it as web application : $. when using single =uotes for the list of initial 0alues: -3 ora-HIF %. when using no =uotes at all for the list of initial 0alues: -3 OR'-$%GI$ N OR'-$CE% &. when using double =uotes for each 0alue in the list of initial 0alues: -3 no initial 0alues gi0en in Parameterform C. The onl# wa# to get it wor7ing in web reports onl#: add double =uotes in front and at the end of the parameter list Other one possible wor7around is to use following trigger : Report Tri??er A&ter P"r"(eter For() &unction A&terPFor( return boo'e"n i be?in #(!_e(pn"(e#+chr(3G)BB#(!_p"r"(BBchr(3G). return (TR6E). end. 4# implementing the code in the afterParameter orms trigger B: (!_p"r"(:Jchr9&H-OO:m#)empnameOOchr9&H-:B adds =uotes and which becomes finall# double =uotes 'nother

In a Form which will call a report with some parameters. You find that if the text parameter contains "'", You will get the following errors in the log of reports background engine. REP3!455 " *6nta7 err1r 1n 81mmand line Err1r *u9mittin: rep1rt You can't use that as it's an illegal character. hat !ou do is put a little code in so as to change all apostrophes into their "I"# e$ui%alent. &his must also be done for the percent sign '() and others which might be considered illegal in an )*+. &he percent sign is the escape character in "I"# so putting it in an )*+ results in whate%er else is after it to be considered an escape character in ,#- which causes problems.

In short, replace all ' in !our )*+ sent to the *eport .er%er with (/0. If !ou're wondering, the escape code for the percent sign is (/1. In the future, an! other illegal characters, 2ust replace the character with (hex where hex is the hex code for the 3.4II character. 55 H+; ,+ E%&ED *'(GLE QU+,E '( *,R'(G
<ow do #ou embed single =uotes 9 5 - into a character stringM <ow do #ou concatenate a =uote in SALM <ow do #ou place =uotes around a character string in a SAL =uer#M <ow do #ou store an apostrophe into a character 0ariable in PL@SALM EC"(p'e $ ,hen #ou issue either of the following SELE+T statements: *7LH *ELECT - FROM du"'. *7LH *ELECT --- FROM du"'. the following error occurs: OR'-I$FDE: =uoted string not properl# terminated EC"(p'e 2 ,hen #ou issue the following SELE+T statement: *7LH *ELECT --ch"r"cter trin? in =uote -- FROM du"'. the following error occurs: OR'-IIH%&: RO* 7e#word not found where e!pected

*o'ution %e cription# To create a single =uote" concatenate +<R9&H- to the string. +O(+'TE('TE +<R9&H- TO +RE'TE L.TER'L S.(2LE A>OTE EC"(p'e $ --------*7LH *ELECT -te t- BB C4R(3G) BB -c" e- re u't FROM du"'. RE*6LT 555555555 te t-c" e EC"(p'e 2 --------*7LH *ELECT C4R(3G) c FROM du"'. C 5 -

To return the A*C)) 2"'ue o& the in?'e =uote ( - )# *7LH *ELECT A*C))(----) FROM du"'. A*C))(----) 55555555555 3G

>SE % S.(2LE A>OTES TO +RE'TE $ S.(2LE A>OTE 8eep the following two rules in mind: $. Enclose e0er# character string in single =uotes. The single =uote is a string delimiter. %. .nside a string literal" use two consecuti0e single =uotes to create a literal single =uote. EC"(p'e $ 555555555 I in?'e =uote # *ELECT -te t- BB ------ BB -c" eRE*6LT te t--c" e J in?'e =uote # *ELECT -te t- BB -------- BB -c" eRE*6LT te t---c" e 6ou can also implement the abo0e in the following wa#: *ELECT -te t--c" eRE*6LT te t-c" e *ELECT -te t----c" eRE*6LT te t--c" e <ence: a. To create a single =uote" concatenate C single =uotes: 5555 The two single =uotes in the middle define the single =uote. The outside single =uotes are the single =uotes that must surround a string. EC"(p'e 2 555555555 *7LH *ELECT ---- FROM du"'. 5 c FROM du"'. c FROM du"'. c FROM du"'.

c FROM du"'.

EC"(p'e 3 555555555 *7LH *ELECT -te t- BB ---- BB -c" e- re u't FROM du"'. RE*6LT 555555555 te t-c" e b. To place single =uotes around a character string" enclose the character string within & single =uotes: 555 At the t"rt o& " ch"r"cter trin?# the first single =uote defines the start of the character string: it is one of the two single =uotes that surround the string. The second and third single =uotes define the literal single =uote. At the end o& the ch"r"cter trin?# the first and second single =uotes define the literal single =uote. The third single =uote closes the character string: it is the other single =uote that surrounds the string. E!ample C --------*7LH *ELECT ---ch"r"cter trin? in =uote --- re u't FROM du"'. RE*6LT -ch"r"cter trin? in =uote *ore e!amples: EC"(p'e K 555555555 *RW3%O_*7L(-*ELECT %ECO%E(dn"(e0 --NONE--0 N6LL0 --A--) FROM dept W4ERE deptno + $E-). A " re u't0 thi i the *ELECT t"te(ent ent to the d"t"b" e# *ELECT %ECO%E(dn"(e0 -NONE-0 N6LL0 -A-) FROM dept W4ERE deptno + $E EC"(p'e I 555555555 %ECLARE " 1ARC4AR2(2EE). = C4AR($) #+ ----. /E,)N " #+ ---thi i " - BB = BB -=uoted-- trin?- BB =. EN%. String BaB stores: 5this is a 5=uoted5 string5

4uilt-in used 9 rom 6racle Forms 67+ine help)


PROCE%6RE CALL_FORM 9formmodule_name 1'R+<'R%, display (>*4ER, switch_menu (>*4ER, query_mode (>*4ER, data_mode (>*4ER" paramlist_name 1'R+<'R%-: P"r"(eter formmodule_name The name of the called form 9must be enclosed in single =uotes-. Datat#pe is 1'R+<'R%. display 4)%E 9The default.- Oracle orms will hide the calling form before drawing the called form. (O)<.DE Oracle orms will displa# the called form without hiding the calling form. switch_menu NO_REPLACE 9The default.- Oracle orms will 7eep the default menu module of the calling form acti0e for the called form. DO)REPL'+E Oracle orms will replace the default menu module of the calling form with the default menu module of the called form. query_mode NO_76ER8_ONL8 9The default.- Oracle orms will run the indicated form in normal mode" allowing the end user to perform inserts" updates" and deletes from within the called form. 76ER8_ONL8 Oracle orms will run the indicated form in =uer#-onl# mode" allowing the end user to =uer#" but not to insert" update" or delete records. data_mode NO_*4ARE_L)/RAR8_%ATA 9The default.- 't runtime" Oracle orms will not share data between forms that ha0e identical libraries attached 9at design time-. *4ARE_L)/RAR8_%ATA 't runtime" Oracle orms will share data between forms that ha0e identical libraries attached 9at design time-. paramlist_id The uni=ue .D Oracle orms assigns when it creates the parameter list. 6ou can optionall# include a parameter list as initial input to the called form. Datat#pe is P'R'*L.ST. paramlist_name The name #ou ga0e the parameter list ob/ect when #ou defined it. Datat#pe is 1'R+<'R%.

PROCE%6RE OPEN_FORM 9formmodule_name 1'R+<'R%, activate_mode (>*4ER, session_mode (>*4ER, data_mode (>*4ER" paramlist_id P'R'*L.ST-: P"r"(eter # formmodule_name The name of the form to open. Datat#pe is 1'R+<'R%. Required activate_mode ACT)1ATE 9The default.- Sets focus to the form to ma7e it the acti0e form in the application. NO_ACT)1ATE Opens the form but does not set focus to the form. The current form remains current. session_mode NO_*E**)ON 9The default.- Specifies that the opened form should share the same database session as the current form. POST and +O**.T operations in an# form will cause posting" 0alidation" and commit

processing to occur for all forms running in the same session. SESS.O( Specifies that a new" separate database session should be created for the opened form.

data_mode NO_*4ARE_L)/RAR8_%ATA 9The default.- 't runtime" Oracle orms will not share data between forms that ha0e identical libraries attached 9at design time-. S<'RE)L.4R'R6)D'T' 't runtime" Oracle orms will share data between forms that ha0e identical libraries attached 9at design time-. paramlist_name The name of a parameter list to be passed to the opened form. Datat#pe is 1'R+<'R%. paramlist_id The uni=ue .D that Oracle orms assigns to the parameter list at the time it is created. >se the 2ET)P'R'*ETER)L.ST function to return the .D to a 0ariable of t#pe P'R'*L.ST.

PROCE%6RE NEW_FORM 9formmodule_name 1'R+<'R%, rollback_mode (>*4ER, query_mode (>*4ER, data_mode (>*4ER" paramlist_name 1'R+<'R%-: P"r"(eter formmodule_name Then name of the called form 9must be enclosed in single =uotes-. Datat#pe is 1'R+<'R%. rollback_mode TO_*A1EPO)NT 9The default.- Oracle orms will roll bac7 all uncommitted changes 9including posted changes- to the current form5s sa0epoint. (O)ROLL4'+8 Oracle orms will e!it the current form without rolling bac7 to a sa0epoint. 6ou can lea0e the top le0el form without performing a rollbac7" which means that #ou retain an# loc7s across a (E,) OR* operation. These loc7s can also occur when in0o7ing Oracle orms from an e!ternal &2L program. The loc7s are still in effect when #ou regain control from Oracle orms. >LL)ROLL4'+8 Oracle orms rolls bac7 all uncommitted changes 9including posted changes- that were made during the current Runform session. 6ou cannot specif# a >LL)ROLL4'+8 from a form that is running in post-onl# mode. 9Post-onl# mode can occur when #our form issues a call to another form while unposted records e!ist in the calling form. To a0oid losing the loc7s issued b# the calling form" Oracle orms pre0ents an# commit processing in the called form.query_mode NO_76ER8_ONL8 9The default.- Runs the indicated form normall#" allowing the end user to perform inserts" updates" and deletes in the form. A>ER6)O(L6 Runs the indicated form in =uer#-onl# mode: end users can =uer# records" but cannot perform inserts" updates or deletes. data_mode NO_*4ARE_L)/RAR8_%ATA 9The default.- 't runtime" Oracle orms will not share data between forms that ha0e identical libraries attached 9at design time-. S<'RE)L.4R'R6)D'T' 't runtime" Oracle orms will share data between forms that ha0e identical libraries attached 9at design time-.

paramlist_id The uni=ue .D Oracle orms assigns when it creates the parameter list. Specif# a parameter list when #ou want to pass parameters from the calling form to the new form. Datat#pe is P'R'*L.ST. ' parameter list passed to a form 0ia (E,) OR* cannot contain parameters of t#pe D'T')P'R'*ETER 9a pointer to record group-. paramlist_name The name #ou ga0e the parameter list ob/ect when #ou defined it. Datat#pe is 1'R+<'R%. ' parameter list passed to a form 0ia (E,) OR* cannot contain parameters of t#pe D'T')P'R'*ETER 9a pointer to record group-.

F6NCT)ON R6N_REPORT_O/DECT 9report_name 1'R+<'R%" paramlist_id P'R'*L.ST-: Returns 1'R+<'R% P"r"(eter report_id Specifies the uni=ue .D of the report to be run. 6ou can get the report .D for a particular report using the 4uilt-in F)N%_REPORT_O/DECT report_name The name of the report ob/ect to run. paramlist_name The name #ou ga0e the parameter list ob/ect when #ou defined it. Datat#pe is 1'R+<'R%. paramlist_id The uni=ue .D Oracle orms assigns when it creates the parameter list. Datat#pe is P'R'*L.ST.

You might also like