Wednesday, December 10, 2014

Forms: NAME_IN and COPY in Forms

Name_In function : 

You can reference items indirectly with the NAME_IN and COPY built-in subprograms. The NAME_IN function returns the contents of an indicated variable or item. Use the NAME_IN function to get the value of an item without referring to the item directly. 

The following two statements retruning the content of an indicated variable ('global.'||name_in('system.cursor_block')||'_active'

1)IF name_in('global.'||name_in('system.cursor_block')||'_active') = 'Y' THEN
property();

2)name_in('global.privelege') NOT IN ('A','D') then 
error menu 

Copy Procedure : The COPY procedure assigns an indicated value to an indicated variable or item. Unlike standard PL/SQL assignment, however, using the COPY procedure allows you to indirectly reference the item whose value is being set: 

3)copy('I',name_in('system.cursor_block')||'.active_status');



COPY can be used with the NAME_IN function to assign a value to an item whose name is stored in a reference variable or item: 

/* put value 'KING' in item whose name is stored in ref_item */ 
Copy('KING',Name_In('control.ref_item')); 

More in Name_In and copy 

Why Use Indirect Reference Referencing items indirectly allows you to write more generic, reusable code. By using variables in place of actual item names, you can write a subprogram that can operate on any item whose name has been assigned to the indicated variable. 
Also, using indirect reference is mandatory when you refer to the value of a form bind variable (item, parameter, global variable) in PL/SQL that you write in a library or a menu module. Because libraries, menus, and forms are separate application modules, you cannot refer directly to the value of a form item in a menu-item command or library procedure.

1 comment: