A variable contains volatile information of a specific data type.


 { identifier [,...] type-specification
 | identifier type-specification [ = initializer ]
 } [,...]
where type-specification is:
{ data-type
| LIKE [dbname:]tabname.colname
   [ attributes-list ]
or type-specification is a function type definition:
     parameter-name data-type [ attributes-list ]
 [ attributes-list ]
 [ RETURNS { data-type [ attributes-list ]
             | ( [ data-type [ attributes-list ] [,...] ] )
             } ]
where attributes-list is:
ATTRIBUTES ( attribute [ = "value" ] [,...] )
where initializer is a variable initialization specification:
{ scalar-initializer
| record-initializer
| array-initializer
where scalar-initializer is:
{ integer-literal
| decimal-literal
| mdy-date-literal
| datetime-literal
| interval-literal
| boolean-literal
where record-initializer is:
( identifier : initializer [,...] ) 
and array-initializer is:
[ initializer [,...] ]
  1. identifier is the name of the variable or record member.
  2. data-type can be a primitive data type, a record definition, an array definition, a user defined type, a built-in class, an imported package class, or a Java class.
  3. dbname identifies a specific database schema file.
  4. tabname.colname references a column defined in the database schema file.
  5. attribute is an attribute to extend the variable definition with properties.
  6. value is the value for the variable attribute, it is optional for boolean attributes.
  7. mdy-date-literal is an MDY(mm,dd,yyyy) specification.


A variable is a named location in memory that can store a single value, or an ordered set of values. Variables can be global to the program, module-specific, or local to a function.

Any program variable needs to be declared with a DEFINE statement before it is used.

A variable is typically defined with a data type.

The variable name must follow the convention of identifiers.

By default, module-specific variables are private; They cannot be used by an other module of the program. In order to improve code re-usability by data encapsulation, we recommend you keep module variables private, except if you want to share large data (like arrays) between modules. To make a module variable public, add the PUBLIC keyword before DEFINE. When a module variable is declared as public, it can be referenced in another module by using the IMPORT FGL instruction.

When defining variables with the LIKE clause, the data types are taken from the database schema file at compile time. Make sure that the schema file of the database schema during development corresponds to the database schema of the production database; otherwise the variables defined in the compiled version of your modules will not match the table structures of the production database. For more details, see Database column types.

To write well-structured programs, avoid global variables. If you need persistent data storage during a program's execution, use variables local to the module and give access to them with functions, or make the module variables PUBLIC to other modules. For more details, see Declaration context.

Variables can be defined with the ATTRIBUTES() clause, to specify meta-data information for the variable. For more details, see Definition attributes.

Variables can be defined to hold a function reference. Best practice is to declare a user-defined type with the function type, then define the variables using the user type.

By adding an equal sign followed by a value, you can save an additional LET instruction to initialize variables. Initializers are especially useful to set values of structured variables (records, arrays) . For more details, see Variable default values.