# 1

# Variables in SQL code

Variables (sometimes refered to as placeholders) are places in SQL code which are replaced by actual values when the SQL code is executed. The benefits are faster execution times (as the SQL code is parsed only once) and a protection against SQL injection vulnerabilities.

Variables can be used in any SQL code, and are defined using the following syntax:

##<variable name>[::<variable type>[::NULL]]

Notes:

the variable name can contain any SQL identifier character or among the `+-.|@?`characters (no space allowed)

the variable type can be among: `string`, `boolean`, `int`, `date`, `time`, `timestamp`, `guint`, `blob` and `binary`

the `::NULL` can be appended to specify that the variable may take the special `NULL` value.

Examples:

##name::string ##id::int::NULL ##sales@3::date::NULL ##customers@id::int