The VALUES INTO statement produces a result table consisting of at most one row and assigns the values in that row to host variables.
This statement can only be embedded in an application program. It is an executable statement that cannot be dynamically prepared.
If an expression includes a function, the authorization ID of the statement must include at least one of the following for each user-defined function:
The authorization ID of the statement has the EXECUTE privilege on a function when:
If a row-subselect is specified, see Queries for an explanation of the authorization required for each subselect.
.-,----------------.
V |
>>-VALUES--+-+-expression--------------+-------------------+---INTO-----host-variable---+->
| +-NULL--------------------+ |
| '-(--scalar-subselect--)--' |
| .-,----------------------------. |
| V | |
'-(--+----+-expression--------------+--+-+---)--'
| +-NULL--------------------+ |
| '-(--scalar-subselect--)--' |
'-row-subselect---------------------'
>--------------------------------------------------------------><
|
If an error occurs as the result of an arithmetic expression in the expression or SELECT list of the subselect (division by zero, or overflow) or a character conversion error occurs, the result is the null value. As in any other case of a null value, an indicator variable must be provided. The value of the host variable is undefined. In this case, however, the indicator variable is set to -2. Processing of the statement continues as if the error had not occurred. (However, this error causes a positive SQLCODE.) If you do not provide an indicator variable, a negative value is returned in the SQLCODE field of the SQLCA. It is possible that some values have already been assigned to host variables and will remain assigned when the error occurs.
If an error occurs, no value is assigned to the current host variable. However, if LOB values are involved, there is a possibility that the corresponding host variable was modified, but the variable's contents are unpredictable.
If the specified host variable is character and is not large enough to contain the result, 'W' is assigned to SQLWARN1 in the SQLCA. The actual length of the result is returned in the indicator variable associated with the host-variable, if an indicator variable is provided.
If the specified host variable is a C NUL-terminated host variable and is not large enough to contain the result and the NUL-terminator:
Assign the value of the CURRENT PATH special register to host variable HV1.
EXEC SQL VALUES CURRENT PATH INTO :HV1;
Assume that LOB locator LOB1 is associated with a CLOB value. Assign a portion of the CLOB value to host variable DETAILS using the LOB locator.
EXEC SQL VALUES (SUBSTR(:LOB1,1,35)) INTO :DETAILS;