Previous Topic: DROP TABLE StatementNext Topic: INSERT Statement


FETCH Statement

Issue a FETCH statement to retrieve the values in the row that a cursor occupies. Usually this statement is executed within a loop that the SQLCODE variable controls so that the SQL server processes each row that a cursor accesses and exits the loop when the end of the table is detected.

Syntax

LSQL FETCH cursorname INTO (hostvarlist )

Parameters

cursorname

Name of the cursor from which you are retrieving values.

hostvarlist

Set of host variable names in which to store the selected column values.

Specify a name for each column that is defined in the SELECT clause of the DECLARE CURSOR statement in the appropriate order.

Note: If you do not specify a host variable for each column that is defined in the cursor, the statement executes and a warning message is returned.

Example

To retrieve the values from the example cursor that is named STATDOWN, issue this LSQL command from a CLIST:

LSQL FETCH STATDOWN INTO (:APPLID,:UPDATE,:STATUS)