Assigns a value to a target parameter or a variable name.
1 – Environment
You can use the SET assignment control statement in a compound
statement:
o In interactive SQL
o Embedded in host language programs to be precompiled
o As part of a procedure in an SQL module
o In dynamic SQL as a statement to be dynamically executed
2 – Format
(B)0[m[1mset-assignment-statement = [m [1m [m [1;4mSET[m[1m qwq> <parameter> qqqqqwq> = qqwqq> value-expr qwq>[m [1m mq> <variable-name> qj mqq> [1;4mNULL[m[1m qqqqqqqj [m
3 – Arguments
3.1 – NULL
Assigns the NULL value to a target parameter or variable name.
3.2 – parameter
Specifies the target where SQL stores a value expression or the
NULL value.
3.3 – value-expr
Assigns the value of a value expression to a target parameter or
variable name.
3.4 – variable-name
Specifies the target where SQL stores a value expression or the
NULL value.
4 – Examples
Example 1: Assigning a value expression to a target parameter
BEGIN
SET :y = (SELECT COUNT (*) FROM employees);
END;
Example 2: Assigning the NULL value expression to a target
parameter
BEGIN
SET :z = NULL;
END;