


An SQL-PL variable is either a simple variable, i.e. it contains a single value at any point in time, or it is a vector, i.e. it contains several values which can be accessed by means of an integer index value. The values of these variables are either strings or numbers and they can also be undefined (the NULL value). Before the first assignment of a value, every variable and every vector element is undefined.
Variables can assume values of any type. These values are implicitly converted, if this is necessary. If this is not possible, the result is the NULL value. For screen output numbers are typically converted into strings, and for arithmetic expressions strings are typically converted into numbers. The NULL value cannot be converted into a number.
Examples:

SQL-PL variables are distinguished by their scope of validity.
Global variables
are available in all routines and forms of a program.
Within a program, the same name of a global variable designates precisely the same variable.
Local-dynamic variables
are only known to the module in which they are used. Local variables are declared with the VAR statement following the module header. All parameters are implicitly declared as local-dynamic. In different modules of a program the same name of a local-dynamic variable designates different variables.
When a module is left, the values of the local-dynamic variables are deleted. When the module is recalled, they are undefined again.
Local-static variables
only differ from local-dynamic variables by the fact that their values are kept even after leaving the module, thus being available again when the module is recalled. These values are only deleted when the program is terminated. Local-static variables are also declared with the VAR statement following the module header.
In different modules of a program the same name of a local-static variable designates different variables. The value of a local-static variable can only be retrieved in the module in which it has been defined.
Local-static variables in functions maintain their values until the start program has been terminated. If a program system is constructed in which a start program branches to several subprograms which all use the same functions, then these subprograms address all the same local-static variables via functions.
After using a variable for the first time, the decision is taken whether it is a scalar or a vector.
If the variables are not explicitly defined by means of the VAR statement, the naming conventions from earlier versions apply.
Example:

The variables MESSAGE and ERROR
are special variables because they exist only once for the entire application. They can be assigned in any module and are always automatically output by the next form if they are not explicitly initialized with NULL.
The variable MESSAGE serves to display information. The ERROR variable serves to display error messages. Both variables are displayed in the same line of the screen, but with different screen attributes (see User-specific SET Parameters menu, PRESENTATION menu, info message and error message in chapter User-specific SET Parameters ). If both variables have a value, only the ERROR variable is output.
The position of the system line for displaying the MESSAGE and ERROR variables is determined by the form interpreter if it has not been explicitly defined as a form output field of the variable MESSAGE (<MESSAGE).
The variables MESSAGE and ERROR are immediately reset to NULL after they have been displayed in a form.
The values of the MESSAGE and ERROR variables are kept beyond a program change made by means of SWITCH or SWITCHCALL (see chapter General Points on Forms and Menus ).
Syntax:



