SET Statement [ESQL]

Assigns a value to an SQL variable.

Quick Links:

Go to Examples

Go to Usage

Go to Standards

Go to Permissions

Syntax

SET identifier = expression

Examples

(back to top)

Usage

(back to top)

The SET statement assigns a new value to a variable that was previously created using the CREATE VARIABLE statement.

You can use a variable in an SQL statement anywhere a column name is allowed. If there is no column name that matches the identifier, the database server checks to see if there is a variable that matches, and uses its value.

Variables are local to the current connection, and disappear when you disconnect from the database or when you use DROP VARIABLE. They are not affected by COMMIT or ROLLBACK statements.

Variables are necessary for creating large text or binary objects for INSERT or UPDATE statements from Embedded SQL programs because Embedded SQL host variables are limited to 32,767 bytes.

Standards

(back to top)

  • SQL—ISO/ANSI SQL compliant.
  • SAP Sybase Database product—Not supported. In Adaptive Server, variables are assigned using the SELECT statement with no table, a Transact-SQL syntax that is also supported by SAP Sybase IQ. The SET statement is used to set database options in Adaptive Server.

Permissions

(back to top)

None

Related reference
CREATE VARIABLE Statement
DROP VARIABLE Statement