8. SQL Statements : FETCH : Syntax
 
Share this page                  
Syntax
The FETCH statement has the following formats:
Non-dynamic version:
EXEC SQL FETCH [FROM] cursor_name
              INTO variable[:indicator_var] {, variable[:indicator_var]};
Dynamic version:
EXEC SQL FETCH [FROM] cursor_name USING DESCRIPTOR descriptor_name;
FROM cursor_name
Specifies the name of an open cursor. Cursor_name can be either a string constant or a host language variable.
USING DESCRIPTOR descriptor_name
Identifies an SQLDA that contains type descriptions of one or more host language variables. Each element of the SQLDA is assigned the corresponding value in the current row of the cursor. For details, see the chapter “Working with Embedded SQL.”
Note:  To retrieve long varchar columns, specify a DATAHANDLER clause in place of the host language variable. For more information, see Data Handlers for Large Objects (see Data Handlers for Large Objects) and the Embedded SQL Companion Guide. The syntax for the DATAHANDLER clause is as follows:
DATAHANDLER(handler_routine ([handler_arg]))[:indicator_var]