5. Working with a Database : How You Can Access a Database with Standard SQL Statements : How You Can Use the Execute Immediate Statement : How You Can Use the Into Clause with a Select Statement
 
Share this page                  
How You Can Use the Into Clause with a Select Statement
You must use the into clause if the statement_string is a select statement. When the statement is executed, the values retrieved by the select statement are placed in the specified variables. The data types of the variables must match those in the target list of the select statement. The number of columns selected must also match the number of targets specified.
For example, assume that your application contains the following code:
statement = 'Select title, vidno from video';
The following execute immediate statement runs the select statement and puts the values returned in the vidtitle and vidno variables:
execute immediate :statement into :vidtitle, :vidno;
If you do not know the names and data types of the target variables until runtime, create an SQLSelect or a query object to build the retrieval statement dynamically. For more information about dynamic query creation, see How You Can Access a Database with DataStream Objects (see How You Can Access a Database with DataStream Objects) and How You Can Use Query Objects (see How You Can Use Query Objects).