SQL Notebook (logo)

DECLARE Statement

Creates a new variable. Variables must be declared before use. Variables have script scope. That is, the variable can be used anywhere else in the script, but it will not be visible to other scripts called using EXECUTE, nor to the parent script if this script was itself called with EXECUTE. Variable names must begin with an at sign (@), dollar sign ($), or colon (:).

If the PARAMETER keyword is used, then the variable becomes a parameter to the script. If the script is called using EXECUTE, then the caller must provide a value for this parameter unless the DECLARE PARAMETER statement specifies an initial-value.

If the DECLARE statement does not include the PARAMETER keyword and does not specify an initial-value, then the variable takes the initial value of NULL.

Unlike other popular SQL scripting languages, SQL Notebook's DECLARE statement does not require a data type to be specified. Variables follow the SQLite convention of allowing any data type to be stored.

Syntax

Syntax for the DECLARE statement.

Arguments

Examples