Previous Topic: Code Example 2Next Topic: Example


Assignment Statement

The assignment statement stores a value into an SQL variable or SQL parameter.

Following is the syntax for the assignment statement:

►►─ SET ─ assignment-target=proc-value-expression ────────────────────────────►◄

Expansion of Where assignment-target is defined as

├──┬─ SQL-variable-name ──┬────────────────────────────────────────────────────┤
   └─ SQL-parameter-name ─┘
assignment-target

For the assignment-target specify an SQL-variable-name or an SQL-parameter-name.

proc-value-expression

For a description of a proc-value-expression, see CASE Statement.

SQL-variable-name

The SQL-variable-name is the name of a variable that is declared within a compound statement inside a SQL Procedure (a LANGUAGE SQL procedure). If the name conflicts with (matches) another SQL variable name from a nested compound statement (for example, a condition handler), or an SQL parameter name, or a column contained within a referenced table or view, the SQL variable name should be qualified using the start-label of the compound statement that immediately contains it.

SQL-parameter-name

The SQL-parameter-name is required for SQL Procedures and, though optional for all others, is recommended for all others as well. The SQL-parameter-name is the name of a parameter passed to a SQL Procedure (a LANGUAGE SQL procedure). When used in a SQL Procedure containing an SQL variable with a conflicting (matching) name, or a table or view reference where the table or view contains a conflicting column name, the name should be qualified by using the procedure name.