8. OpenSQL Statements : Select (embedded) : Retrieving Values into Host Language Variables
 
Share this page                  
Retrieving Values into Host Language Variables
The INTO clause specifies the host program variables into which the values retrieved by the select are loaded. There must be a one‑to‑one correspondence between expressions in the SELECT clause and the variables in the INTO clause. If the statement does not retrieve any rows, the variables are not modified. If the number of values retrieved from the database is different from the number of columns, an error is issued and the sqlwarn3 variable of the SQLCA is assigned the value 'W'. Each result variable may have an indicator variable for null data.
Host language variables can be used as expressions in the SELECT clause and the search_condition, in addition to their use in the INTO clause. Variables used in search_conditions must denote constant values and cannot represent names of database columns or include any operators. Host string variables can also substitute for the complete search condition.