Variables

SQL Anywhere supports three levels of variables:

  • Local variables   These are defined inside a compound statement in a procedure or batch using the DECLARE statement. They exist only inside the compound statement.

  • Connection-level variables   These are defined with a CREATE VARIABLE statement. They belong to the current connection, and disappear when you disconnect from the database or when you use the DROP VARIABLE statement.

  • Global variables   These are system-supplied variables that have system-supplied values. All global variables have names beginning with two @ signs. For example, the global variable @@version has a value that is the current version number of the database server. Users cannot define global variables.

Local and connection-level variables are declared by the user, and can be used in procedures or in batches of SQL statements to hold information. Global variables are system-supplied variables that provide system-supplied values.

 See also
 Standards and compatibility

Local variables
Connection-level variables
Global variables