INITIALIZE

The INITIALIZE instruction initializes program variables with NULL or default values.

Syntax

INITIALIZE target [,...]
  {
     TO NULL
  |
     LIKE {table.*|table.column}
  }
  1. target is the name of the variable to be initialized.
  2. table.column can be any column reference defined in the database schema file.

Usage

The INITIALIZE instruction assigns NULL or default values to variables.

The argument of the INITIALIZE instruction can be a simple variable, a record (with or without .* notation), a record member, a range of record members specified with the THRU keyword. It is also possible to initialize arrays and dictionaries.

The TO NULL clause initializes the specified variables to null, or clears a variable defined with a collection type:
  1. With a variable defined with a primitive type, the variable is set to NULL.
  2. With a record variable, all members are initalized individually to NULL. If the record contains sub-records, these will also be initialized.
  3. With a static array TO NULL, all elements will be initialized to null.
  4. With a dynamic array TO NULL, all elements will be removed.
  5. With a dictionary TO NULL, all elements will be removed.

The LIKE clause initializes the variable to the default value defined in the database schema validation file. This clause works only by specifying the table.column schema entry corresponding to the variable.

To initialize a complete RECORD, use the star to reference all members:
INITIALIZE record.* LIKE table.*

Variables defined with a complex data type (like TEXT or BYTE) cannot by initialized to a non-NULL value.

Example

SCHEMA stores 
MAIN
  DEFINE cr RECORD LIKE customer.*
  DEFINE a1 ARRAY[100] OF INTEGER
  INITIALIZE cr.cust_name TO NULL
  INITIALIZE cr.cust_name THRU cr.cust_address TO NULL
  INITIALIZE cr.* LIKE customer.*
  INITIALIZE a1 TO NULL
  INITIALIZE a1[10] TO NULL
END MAIN