A DECLARE CURSOR statement must have corresponding OPEN, FETCH and CLOSE statements in the same source program for the execution of the OPEN to proceed without error.
Cursors must be declared in the source:
If an exception declaration (WHENEVER statement) is not provided, the recommended practice is for your program to include code to check the returned value of the SQLCODE immediately after each executable SQL statement. If you do not use a WHENEVER statement, however, be aware of the following:
Cursor definitions are declarations, not operational (procedural) statements, and as such are used for Preprocessor input only. Because no call is sent to the Multi-User Facility, checking the SQLCODE after a DECLARE CURSOR statement always shows the SQLCODE received by whatever statement immediately preceeded the DECLARE CURSOR statement.
In COBOL, cursor declarations can be made in the:
Note: The recommended practice is to place all cursor definitions immediately before the PROCEDURE DIVISION source statement. But if you do not use a WHENEVER statement and want to avoid any potential confusion resulting from the content of the SQLCODE after a DECLARE CURSOR statement, place all of your DECLARE CURSOR statements in the WORKING-STORAGE SECTION.
|
Copyright © 2014 CA.
All rights reserved.
|
|