Variable default values

Variables get a default value when defined.

By default, variables are initialized to a value depending on the variable data type.

For example, when defining an INTEGER variable, it gets zero as default value, while a DECIMAL variable is set to NULL:
MAIN
    DEFINE v1 INTEGER, v2 DECIMAL(10,2)
    DISPLAY v1  -- Shows "0"
    DISPLAY NVL(v2,"null") -- Shows "null"
END MAIN

The next table lists default initialization values for each primitive data type:

Table 1. Data type specific default values for variables
Data type Default Value
CHAR NULL
VARCHAR NULL
STRING NULL
BIGINT Zero
INTEGER Zero
SMALLINT Zero
TINYINT Zero
BOOLEAN FALSE
FLOAT Zero
SMALLFLOAT Zero
DECIMAL NULL
MONEY NULL
DATE 1899-12-31 (= Zero in number of days)
DATETIME NULL
INTERVAL NULL
TEXT NULL, must use LOCATE
BYTE NULL, must use LOCATE