Part36 parameter,form success

17
PART 36- PARAMETER FORM_SUCCESS Dr. Girija Narasimhan

description

parameter, form_success, exception, add_parameter, destroy_parameter,oracle 10g, oracle 10g form builder

Transcript of Part36 parameter,form success

Page 1: Part36 parameter,form success

PART 36- PARAMETER

FORM_SUCCESS

Dr. Girija Narasimhan

Page 2: Part36 parameter,form success

Referencing Parameters

In PL/SQL, you can reference and set the values of form parameters using bind variable syntax.

To reference a parameter: Preface the parameter name with the reserved word PARAMETER, as shown in the following examples:

:PARAMETER.parameter_name := ‘p_deptno';

Or :dept.deptno:= :PARAMETER.p_deptno;

Dr. Girija Narasimhan

Page 3: Part36 parameter,form success

Alternative method

Object Navigator parameters create new parameter(parameter2)Property Palette Name change as ‘p_deptno’

Parameter data type -> number

Maximum length -> 2

Parameter initial value -> 10

Dr. Girija Narasimhan

Page 4: Part36 parameter,form success

Dr. Girija Narasimhan

PROCEDURE ADD_PARAMETER(list VARCHAR2, key VARCHAR2, paramtype NUMBER, value VARCHAR2);

ADD_PARAMETER Restrictions

A parameter list can consist of 0 (zero) or more parameters.

You cannot create a parameter list if one already exists; to do so will cause an error. To avoid this error, use ID_NULL to check to see if a parameter list already exists before creating one. If a parameter list already exists, delete it with DESTROY_PARAMETER_LIST before creating a new list.

You cannot add a parameter of type DATA_PARAMETER if the parameter list is being passed to another form

Page 5: Part36 parameter,form success

Dr. Girija Narasimhan

list or name  Specifies the parameter list to which the parameter is assigned. The actual parameter can be either a parameter list ID of type PARAMLIST, or the VARCHAR2 name of the parameter list.

 key  The name of the parameter. The data type of the key is VARCHAR2.  

paramtype  Specifies one of the following two types: TEXT_PARAMETER A VARCHAR2 string literal.

DATA_PARAMETER A VARCHAR2 string specifying the name of a record group defined in the current form. When Oracle Forms passes a data parameter to Reports or Graphics, the data in the specified record group can substitute for a query that Reports or Graphics would ordinarily execute to run the report or display.

 value  The actual value you intend to pass to the called module. If you are passing a text parameter, the maximum length is 64K characters. Data type of the value is VARCHAR2.

Page 6: Part36 parameter,form success

Dr. Girija Narasimhan

Searches the list of parameter lists and returns a parameter list ID when it finds a valid parameter list with the given name.

You must define an variable of type PARAMLIST to accept the return value.

This function is similar to the FIND_ functions available for other objects.

GET_PARAMETER_LIST Built-in

FUNCTION GET_PARAMETER_LIST(name VARCHAR2);

Page 7: Part36 parameter,form success

Use FORM_SUCCESS to test the outcome of a built-in to determine further processing within any trigger.

To get the correct results, you must perform the test immediately after the action executes.

That is, another action should not occur prior to the test. "Another action" includes both built-ins and PL/SQL assignment statements.

If another action occurs, FORM_SUCCESS may not reflect the status of the built-in you are testing, but of the other, more recently executed action.

Dr. Girija Narasimhan

FORM_SUCCESS

Page 8: Part36 parameter,form success

Step 1: create parameter

Page 9: Part36 parameter,form success

Step 2: create data block “dept”

Step 3: quit button write “exit_form”

Step 4: when_new_form_instance –write ‘execute_query’

Page 10: Part36 parameter,form success

Step 5: in the dept data block property palette where clause deptno=:parameter.p_deptno

Page 11: Part36 parameter,form success

Step 6: create emp data block as tabular format

Step 7: create control block create item push button as “show_me_department_info”

Page 12: Part36 parameter,form success

Step 8: In show_me_department_info push button when_button_pressed trigger write following coding given in slide 13, slide 14

Page 13: Part36 parameter,form success

DECLARE

p_id paramList; -- This is a variable that contains id of the parameter list

p_name VARCHAR2(20); -- A variable that keeps your parameter name BEGIN

p_name := 'myparameter';

p_id := GET_PARAMETER_LIST('p_name'); -- find it if exists. IF NOT ID_NULL (p_id) THEN

-- If exit then destroy it.

DESTROY_PARAMETER_LIST(p_id);

END IF; --Now create a parameter list and add your p_deptno parameter.

p_id := CREATE_PARAMETER_LIST('p_name');

ADD_PARAMETER(p_id,'P_DEPTNO',TEXT_PARAMETER,to_char(:deptno));

Page 14: Part36 parameter,form success

--- You can call the called program either by default or specific like c:.

OPEN_FORM('e:\tutorial\dept.fmx',ACTIVATE,SESSION,p_id);-- Error messages in case the called program was not able

-- to open called program.

IF NOT FORM_SUCCESS THEN

MESSAGE('ERROR: Unable to open the DEPARTMENT form.');

RAISE FORM_TRIGGER_FAILURE;

END IF;

EXCEPTION

WHEN others THEN

MESSAGE ('Error: unable to create parameter list…');

RAISE FORM_TRIGGER_FAILURE;

END;

Page 15: Part36 parameter,form success

Step 9 : compile dept.fmb and emp.fmb

Step 10: Run emp.fmb

Page 16: Part36 parameter,form success

Step 11: instead of dept.fmx give dep.fmx and check whether form_success and exceptions are working

Page 17: Part36 parameter,form success

Reference:

everythingOracle.bizhat.com \chapter 22