SQL/MX 2.x Reference Manual (H06.04+)

Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
3-75
SET (Assignment) Statement
SET (Assignment) Statement
C Examples of Assignment Statement
An assignment statement in a compound statement assigns a value to a host variable
so that subsequent statements in the containing compound statement can reference
and use the value of that host variable.
SET is an SQL/MX extension that you use only in embedded SQL programs in C or
COBOL.
assignment-target
specifies a list of host variable specifications in which to return the values in the
assignment-source.
The number of items in assignment-source must be equal to the number of
specified host variables, and the data type of each source value must be
compatible with the data type of its target host variable.The first value in the
assignment-source is assigned to the first host variable, the second value to
the second variable, and so on.
You can use rowset host variables as assignment-targets if either the
assignment-source is a subquery that returns more than one row, or the
assignment-source includes rowset-expressions. In this case you can use
rowset host variables in the assignment-target to return values from multiple
consecutive rows in the assignment-source.
The values of the host variables that have been set by an assignment statement
are made available for use by subsequent statements within the compound
statement and by other statements that follow after that compound statement.
:variable-name [[INDICATOR] :indicator-name]
is a variable specification—a host variable with optionally an indicator variable.
A variable name begins with a colon (:).
SET assignment-target = assignment-source
assignment-target is:
variable-spec [,variable-spec]...
assignment-source is:
subquery
| {expression | rowset-expression | NULL}
[,{expression | rowset-expression | NULL]...
C/COBOL