Reference Guide > TDV SQL Script > SQL Script Statement Reference > SET
 
SET
The SET statement in SQL Script is an assignment statement that assigns a value to a variable.
Syntax
SET <varName> = <value>
Remarks
Values are coerced (implicitly cast) if that is possible.
ROW values can be assigned to ROW variables only if each of the fields in the ROW variable could be assigned independently. Fields are coerced (implicitly cast) as required.
A cursor variable with a type can be assigned from any cursor with the same ROW type, or to any cursor variable with exactly the same ROW type.
A cursor variable without a type can be assigned from any cursor, or to any cursor. Assigning to a typed cursor forces a runtime schema match comparison and raises an exception on a mismatch.
Assigning a cursor creates a reference to the original cursor’s state. This means that opening, closing, or fetching from the original cursor or the variable has the same effect and alters what the other would see. See OPEN, CLOSE, and FETCH for details on opening, closing, and fetching actions on cursors.
Errors
The following table describes the errors that can occur when executing a SET statement.
Error Message
Cause
Cannot alter the value of an IN parameter
The specified variable is an IN parameter.