Adsense Ad

Wednesday, 5 December 2018

Oracle Forms: COPY built-in

Description
Copies a value from one item or variable into another item or global variable.  Use specifically to write a
value into an item that is referenced through the NAME_IN built-in.  COPY exists for two reasons:
•  You cannot use standard PL/SQL syntax to set a referenced item equal to a value.
•  You might intend to programmatically place characters such as relational operators in NUMBER
and DATE fields while a form is in Enter Query mode.

Syntax
PROCEDURE COPY
  (source       VARCHAR2,
   destination  VARCHAR2);
Built-in Type   unrestricted procedure
Enter Query Mode  yes
Parameters
source The source is a literal value.
destinatioThe destination can be either a text item or another global variable.
Usage Notes
•  When using COPY with date values, the format defined in the BUILTIN_DATE_FORMAT
property will be used if the DATE_FORMAT_COMPATIBILITY_MODE property  is set to 5.0.  If
this property is set to 4.5 COPY will  expect date strings to be formatted using the default American
format.
•  To use a text item as the source reference, you can use the following code:
COPY(NAME_IN(source), destination);
COPY restrictions
No validation is performed on a value copied to a text item.  However, for all other types of items,
standard validation checks are performed on the copied value.
COPY examples
Example 1
/* 
** Built-in:  COPY
** Example:   Force a wildcard search on the EmpNo item during
**            query.
** trigger:   Pre-Query
*/
DECLARE
  cur_val VARCHAR2(40);
BEGIN
51
  /*
  ** Get the value of EMP.EMPNO as a string
  */
  cur_val := Name_In(’Emp.Empno’);
  /*
  ** Add a percent to the end of the string.
  */
  cur_val := cur_val || ’%’;
  /*
  ** Copy the new value back into the item so Form Builder
  ** will use it as a query criterion.
  */
  Copy( cur_val, ’Emp.Empno’ );
END;

Example 2
/* 
** Built-in:  COPY
** Example:   Set the value of a global variable whose name is
**            dynamically constructed.
*/
DECLARE
  global_var_name  VARCHAR2(80);
BEGIN
  IF :Selection.Choice = 5 THEN
    global_var_name := ’Storage_1’;
  ELSE
    global_var_name := ’Storage_2’;
  END IF;
  /*
  ** Use the name in the ’global_var_name’ variable as the
  ** name of the global variable in which to copy the
  ** current ’Yes’ value.
  */
  COPY( ’Yes’, ’GLOBAL.’||global_var_name );
END;

1 comment: