The VALUES INTO statement produces a result table consisting of at most one row and assigns the values in that row to host variables.
Invocation
This statement can be embedded only in an application program. It is an executable statement that cannot be dynamically prepared.
Authorization
None required.
Syntax
>>-VALUES----+-expression----------------+--INTO----------------> | .-,-------------. | | V | | '-(-----expression---+---)--' .-,----------------. V | >--------host-variable---+-------------------------------------><
Description
The first value in the result row is assigned to the first variable in the list, the second value to the second variable, and so on. If the number of host variables is less than the number of column values, the value 'W' is assigned to the SQLWARN3 field of the SQLCA. (See Appendix B, SQL Communications (SQLCA).)
Each assignment to a variable is made according to the rules described in Assignments and Comparisons. Assignments are made in sequence through the list.
If an error occurs, no value is assigned to any host variable.
Examples
Example 1: This C example retrieves the value of the CURRENT PATH special register into a host variable.
EXEC SQL VALUES(CURRENT PATH) INTO :hvl;
Example 2: This C example retrieves a portion of a LOB field into a host variable, exploiting the LOB locator for deferred retrieval.
EXEC SQL VALUES (substr(:locator1,35)) INTO :details;