To meet your needs, we constantly work to improve Querix products.
This means that Lycia documentation is developing as well.
In case you have found a certain dissonance between the provided information and the actual behavior of Lycia 3 and/or your applications, please, let us know about this via documentation@querix.com so that we can introduce the necessary changes to our documentation.
Thank you for your attention and cooperation.
INITIALIZE statement is used to assign initial values to program variables. It can also assign a NULL value.
Element |
Description |
Variable List |
A list of variables of simple data types, RECORD data type or array elements separated by comas |
Column list |
A list of database columns with table qualifiers, if necessary, separated by comas |
Any variable declared with the help of the DEFINE statement has storage space allocated to it. The value assigned to a variable occupies that space. The INITIALIZE can be used with:
LIKE keyword, which assigns the default values of a database column to a variable (they are retrieved from the syscolval system table).
TO NULL keywords, which assign NULL value to a variable (the representation of a NULL value depends on the data type declared).
Variable list can include one or more of the following variable types separated by comas:
Variables of simple data types
Variables of RECORD data types in the following formats:
record.*
record.first_member THRU record.last_member
record.member
Elements of static or dynamic program arrays in the format array[dimensions] where "dimensions" are from one to three integer expressions that specify the position of the array element.
LIKE keyword in the INITIALIZE statement is used to specify the default values from syscolval columns. It requires the default database to be specified, thus the DATABASE keyword must appear before the first program block of the program module where you use the INITIALIZE statement with the LIKE clause.
The variables specified in the variable list must match the database columns specified in the column list in order, number and data types. A column must be prefixed with the name of its table.
INITIALIZE first_v, second_v
LIKE my_table.col1, my_table.col2
If you use the table.* notation, you will assign the default values of every column of a table to the specified variables. The example below assigns the values of all the columns of a table to all the members of a record:
INITIALIZE my_record.* LIKE my_table.*
In an ANSI-compliant database you must specify not only the table name but also its owner, for the tables that are not owned by the current user. In the example below, the third column belongs to the current user, so the owner table qualifier is omitted:
INITIALIZE first_v, second_v, third_v
LIKE j_smith.table1.col1, t_brown.table2.col5, table3.col7
You can include the owner table qualifier in a non ANSI-compliant database, but it is not obligatory. However, an incorrect owner prefix will produce an error.
The default values of columns are retrieved from the syscolval table, any changes in this table are reflected in a program (i.e. in the INITIALIZE statement), only if they are made before the program has been compiled. To apply the changes made after that, you must recompile the program. If a column has no default value, NULL value is assigned to an initialized variable.
You cannot use the LIKE keyword to assign values to the variables of large data types (BYTE and TEXT). They can be assigned only NULL values.
TO NULL clause is used to assign NULL values to variables. The examples below initialize the variables and all record members to NULL:
INITIALIZE first_v, second_v, third_v TO NULL
INITIALIZE my_rec.* TO NULL
The variables are usually initialized to NULL due to such reasons:
To initialize variables that do not have the assigned value
To discard the value assigned to a variable (it may prove useful if you plan to reuse this variable)
In order to optimize performance, you may want to limit the use of the INITIALIZE statement with the TO NULL clause.