The assignment-statement assigns a value to an SQL parameter or SQL variable.
>>-+--------+--SET--assignment-clause-------------------------->< '-label:-'
assignment-clause:
.-,-----------------------------------------------------------------------. V | >>---+-+-SQL-parameter-name-+-- = --+-expression-+-------------------------+-+->< | '-SQL-variable-name--' +-NULL-------+ | | '-DEFAULT----' | | .-,----------------------. .-,--------------. | | V | V | | '-(----+-SQL-parameter-name-+-+--)-- = --+-(----+-expression-+-+--)-+-' '-SQL-variable-name--' | +-NULL-------+ | | '-DEFAULT----' | '-row-fullselect-----------'
Assignment rules: Assignments in the assignment statement must conform to the SQL assignment rules as described in Assignments and comparisons. If assigning to a string variable, storage assignment rules apply.
Assignment rules for SQL parameters: An IN parameter can appear on the left or right side of an assignment-statement. When control returns to the caller, the original value of the IN parameter is retained. An OUT parameter can also appear on the left or right side of an assignment-statement. If used without first being assigned a value, the value is undefined. When control returns to the caller, the last value that is assigned to an OUT parameter is returned to the caller. For an INOUT parameter, the first value of the parameter is determined by the caller, and the last value that is assigned to the parameter is returned to the caller.
Special Registers: If a variable has been declared with an identifier that matches the name of a special register (such as PATH), then the variable must be delimited to distinguish it from assignment to the special register (for example, SET "PATH" = 1; for a variable called PATH declared as an integer).
SQLCODE and SQLSTATE: The SQLCODE and SQLSTATE will be reset and the diagnostic area or SQLCA initialized for each assignment-statement other than assignment-statements that:
Increase the SQL variable p_salary by 10 percent.
SET p_salary = p_salary + (p_salary * .10)
Set SQL variable p_salary to the null value
SET p_salary = NULL