A script-enabled browser is required for this page to function properly.

Referencing Oracle Forms Items Indirectly

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 statements are equivalent:

IF :emp.ename = 'smith' -- direct reference
IF NAME_IN('emp.ename') = 'smith' -- indirect reference

The return value is always a character string. To use NAME_IN for a DATE or NUMBER item, convert the string to the desired data type with the appropriate conversion function:

Date_var := TO_DATE(Name_In('order.Date_item'));
num_var := TO_NUMBER(Name_In('order.number_item'));

Notes on NAME_IN:

The 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:

:emp.ename := 'smith'; -- direct reference
Copy('smith','emp.ename'); -- indirect reference

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 'smith' in item whose name is stored in ref_item */
Copy('
smith',Name_In('control.ref_item'));

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.


COPY Built-in

NAME_IN Built-in