Tuesday, June 9, 2015

In-Direct Global Variable Access


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 ,



          ·      Indirect reference is mandatory when you refer to the value of a form bind variable (item,  parameter, global variable) in a PL/SQL Library or a menu module. Because direct reference CAN NOT be resolved.
            "Read about Direct Global Variable Access to Pass Data to Forms"


Why indirect reference is mandatory?

·        Because libraries, menus, and forms are individual form modules, you cannot refer directly to the value of a form item  or in a menu-item command or in a PL/SQL Library.
·        Referencing items indirectly allows you to write more generic, reusable code.


     ·     Indirect Global Variable Access: 
          Hence, Global variables have an indirect access to form module items like a PL/SQL Library, packages and menu modules. You can't directly reference items on the form in menu code. Oracle forms allow using the feature of in-direct references; you can do indirect referencing to form items and Global variables with the NAME_IN and COPY built-ins.


·COPY () built-in


The Copy () built in procedure simply enables you to set or define the value of any Global variable, form parameter or form item as the following:

Syntax

 BEGIN
COPY(Assigned_value, 'GLOBAL.VARIABLE_NAME');
 END;



Example:
If you want to assign the sysdate() function to a global variable within your Oracle  form PLL library, packages you have to set e.g. GLOBAL.TO_DAY as the following:


 BEGIN
COPY (TO_CHAR (SYSDATE), 'GLOBAL.TO_DAY');
 END;


Then, "Copy" in this case is used to copy a value of the system date to "GLOBAL.TO_DAY".


· NAME_IN built-in


The NAME_IN () built-in function simply enables you to retrieve the value of any Global variable, form parameter or form item with no direct reference to as the following:

Syntax

DECLARE
v_curr_date DATE;
BEGIN
v_curr_date := NAME_IN('GLOBAL.VARIABLE_NAME');
END;

Example:

 You can retrieve the GLOBAL.TO_DAY value within your Oracle form PL/SQL packages using the NAME_IN()


DECLARE
v_curr_date DATE;
BEGIN
v_curr_date := NAME_IN('GLOBAL.TO_DAY');
END;



Use conversion functions for Number and Date data type to cast it back to its initial data type using the TO_NUMBER () or TO_DATE () functions according to the original form item datatype. 


Hope it Helps…



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


References 'Oracle Forms User's Guide' 


No comments :