Previous Topic: CREATE TABLE StatementNext Topic: DELETE FROM Statement


DECLARE CURSOR Statement

The DECLARE CURSOR statement defines a cursor. To establish the location in a table where the cursor is to appear, include a SELECT statement.

LSQL DECLARE cursorname CURSOR FOR selectstatement

Parameters

cursorname

1‑ to 18‑character name of the cursor that you are defining.

selectstatement

Statement that contains the selection criteria for the cursor. For more information, see SELECT Statement.

Note: The LSQL command that executes the DECLARE CURSOR statement must be issued from a CLIST or from a REXX procedure.

Example

Issue this LSQL command from a CLIST to define a cursor that is named STATDOWN and selects the application ID, update time, and status from the APPLICATIONS table when the status is DOWN:

“LSQL DECLARE STATDOWN CURSOR FOR
   SELECT APPL_ID, UPDATE, STATUS FROM APPLICATIONS
   WHERE STATUS='DOWN'”