Previous Topic: CREATE TABLE Statement

Next Topic: DELETE FROM Statement

DECLARE CURSOR Statement

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

LSQL DECLARE cursorname CURSOR FOR selectstatement

Operand

Explanation

cursorname

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

selectstatement

The statement that contains the selection criteria for the cursor. See “SELECT Statement”  for more information.

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

Example

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

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