SQL Reference

VALUES INTO

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

VALUES
Introduces a single row consisting of one of more columns.

expression
An expression that defines a single value of a one column result table.

(expression,...)
One or more expressions that define the values for one or more columns of the result table.

INTO
Introduces a list of host variables.

host-variable
Identifies a variable that is described in the program under the rules for declaring host variables.

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;


[ Top of Page | Previous Page | Next Page ]