Previous Topic: DROP TABLE Statement

Next Topic: INSERT Statement

FETCH Statement

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

Syntax

LSQL FETCH cursorname INTO (hostvarlist )

Operand

Explanation

cursorname

The name of the cursor from which you are retrieving values.

hostvarlist

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

Specify a name for each column 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 defined in the cursor, the statement executes and a warning message is returned.

Example

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

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