Wednesday, June 10, 2015


Three Steps to Forms Data Exchange
"Parameter List"



In the name of Allah, Most Gracious, Most Merciful
Praise be to Allah, blessing and peace be upon our prophet Mohammed, his family and his companions. After that


Task Definition

One of the common tasks that most of Oracle developers are frequently used is passing data between form modules. It enhances more related  and integrated form modules. It also minimize user data input process.



Task Execution Idea: There are two different ways you can use regarding data forms exchanges:
  1.     Global variables.
2.     Parameter List.


Task Solution: The "Parameter List" solution technique is the target what we are concerned to recognize its practice solution.

  How it works?

Let's briefly summarize the life cycle of passing data between two forms into three logical steps to recognize the whole process it looks like a ping pong match between two players or two forms but with ONE way.

  ONE WAY  FORM'S PASSING DATA APPROACH


     The Form's text item data retrieved from database at (form'A')'s run-time  is desired  to pass it's current value to (form 'B')'s text item where a  form's parameter (pre-created at design time) helps in this process by receiving the value sent from form'A' and assigning it to it's appropriate text item( form 'B').



Now Let's  demonstrate a sample code for this approach




  Start Working in form 'A':

§  Create a new form module called form 'A'.
§  Create a data block based on "DEPARTMENTS" Table
§  Create a button, rename it call form 'B'.
§   Create When-Button-Pressed trigger.
§  Paste the following code in When-Button-Pressed trigger.

DECLARE

     Pl_Id PARAMLIST;

BEGIN


/* Let's Start the joy to simplify the Task Solution job*/

/* First you have to get your parameter list.
 It looks like getting (or buying) a container for filling it up with     expected future parameters retrieved from the database shop  */
  
     Pl_Id := GET_PARAMETER_LIST('tempdata');

/* Pls. Check if the container is full then you have empty it for future need of new data parameters */
  
     IF NOT ID_NULL(Pl_Id) THEN

          DESTROY_PARAMETER_LIST(Pl_Id);

     END IF;

 /* Now it's time to create data parameters according to your choice after creating a new & empty parameter list in your memory shop */

  
 Pl_Id := CREATE_PARAMETER_LIST('tempdata');


/*In this stage You can add one or more parameters as you need*/

ADD_PARAMETER
(Pl_Id, 'P_DEPT_NO', TEXT_PARAMETER, TO_CHAR(:DEPT.DEPT_NO));

ADD_PARAMETER(Pl_Id, 'parameter_name', TEXT_PARAMETER,:DEPT.DEPT_NAME);

--- Add parameters as much as needed ---

/* Now it's time to call the second form and pass the parameter list container with one or more data parameters as you previously determined in last step */


      Open_form('form_name', ACTIVATE, SESSION, Pl_Id);     


END;




    Now Let's Start Working in form 'B':


 §  Create a new form "form"  'B' based on any data block you specify.

   All you have to do is to  create WHEN-NEW-FORM-INSTANCE or PRE-FORM trigger, Form-Level and  Paste the following sample code.

   Never forget to Create the Parameter's form from Parameter's form's node in the Object Navigator and follow the guide lines listed below.

  
     IF :PARAMETER.P_DEPT_NO  IS NOT NULL THEN

      GO_BLOCK('DEPATMENTS');     
        
  :DEPATMENTS.DEPT_NO :=:PARAMETER.P_DEPT_NO;
  :DEPATMENTS.DEPT_NAME :=:PARAMETER.P_DEPT_NAME;

     END IF;

-- OPTIONAL WHERE CLAUSE to filter data

SET_BLOCK_PROPERTY('DEPATMENTS', DEFAULT_WHERE,
          ' DEPATMENTS.DEPT_NO = ''' || :PARAMETER.DEPT_NO || '''' || 'AND '  || ' DEPATMENTS.DEPT_NAME = ''' || :PARAMETER.P_DEPT_NAME || ''''  );

  




§  Guide Lines to Oracle form parameter Data types:


   §  Form Parameters data type in both forms 'Must be the same' 
   (Text items created in data block in form 'B' Must be the same name and data type of text parameters' names created in form  'A' 's at memory run-time).

 §   TO_CHAR ()  function 'Must be  used'  in ADD_PARAMETER statement     if and only if required to CAST the Numbers and Date Data Types.

   §  Maximum Length of the parameter property 'Must be the same'; You have       to specify the Maximum Length of each form parameter and each item  in     a data block form item according to your needs.
     
§  Naming convention rules is recommended to use for parameters as:
"P_DEPT_NAME"  or "P_HIRE_DATE".


 Any expressive parameter name explains its contents.


Functional Steps To Test 

  1.           Compile, generate and Save form 'A' and form 'B'.
  2.           Run form 'A'.
  3.           Retrieve the department name value as in the example.
  4.          Press "call form 'B' " button.
  5.          Form 'B' will be opened with the department name value passed from Form 'A'.

Hence, the Form parameter technique is the best solution you can ever rely on concerning passing data between forms. It is strongly recommended choice rather than the Global Variables Solution.


Hope this Helps…


My success only comes from Allah, pls. note your comments and suggestions are great help for me in progress thanks in advance.