DECLARE EXTERNAL CURSOR

The DECLARE EXTERNAL CURSOR data manipulation statement identifies an externally-defined global cursor to be used by the application program. You can use this statement only in SQL that is embedded in a program. The DECLARE EXTERNAL CURSOR statement is a CA IDMS extension of the SQL standard.
idmscu19
The DECLARE EXTERNAL CURSOR data manipulation statement identifies an externally-defined global cursor to be used by the application program. You can use this statement only in SQL that is embedded in a program. The DECLARE EXTERNAL CURSOR statement is a CA IDMS extension of the SQL standard.
Authorization
None required.
Syntax
  ►►─── DECLARE 
static-cursor-name
 EXTERNAL CURSOR ─────────────────────────────►◄  
Parameter
  • static-cursor-name
    Specifies the name of a global cursor to be used by the application program.
    Static-cursor-name
    must identify a cursor defined by a DECLARE CURSOR statement with the GLOBAL option in another application program that shares an access module with the program containing the DECLARE EXTERNAL CURSOR statement.
Usage
Sharing Cursors
For one program (program B) to use a cursor defined in another program (program A):
  • Program A must:
    • Include a DECLARE CURSOR statement that defines the cursor as a global cursor
    • Include an OPEN statement that opens the cursor
    • Open the cursor before program B attempts to use the cursor
  • Program B must include a DECLARE EXTERNAL CURSOR statement that names the cursor
  • The two programs must:
    • Use the same access module
    • Execute within the same transaction
Example
Identifying an Externally Defined Global Cursor
The following DECLARE EXTERNAL CURSOR statement identifies ALL_EMP_CURSOR as an externally defined global cursor that is used in the application program:
EXEC SQL    DECLARE ALL_EMP_CURSOR EXTERNAL CURSOR END-EXEC
More Information
  • For more information about defining global cursors, see DECLARE CURSOR
  • For more information about using cursors in an application program, see the Using a Cursor.