IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

where we declare the cursor


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
crm

New User


Joined: 14 Nov 2005
Posts: 25

PostPosted: Fri Nov 25, 2005 9:45 am
Reply with quote

where we declare the cursor

in Procedure division or in working storage section.
Back to top
View user's profile Send private message
andy6703

New User


Joined: 25 Jul 2005
Posts: 14

PostPosted: Fri Nov 25, 2005 3:04 pm
Reply with quote

Hi crm,

We declare the cursor in the working storage section & perform an open or fetch in the Procedure division.


Andy

God Bless!
Back to top
View user's profile Send private message
sureshchoudey

New User


Joined: 16 Sep 2005
Posts: 12

PostPosted: Wed Nov 30, 2005 1:49 pm
Reply with quote

Place the DECLARE CURSOR Statement First
The DECLARE CURSOR statement must precede any other commands (such as OPEN, CLOSE, and FETCH) relating to the cursor because of the way the DB2 precompiler parses and extracts the SQL statements from the program.

The DECLARE CURSOR statement is not an executable statement and should not be coded in the PROCEDURE DIVISION of an application program. Although doing so does not cause a problem, it makes your program difficult to understand and could cause others to think that DECLARE is an executable statement.

You should place all cursor declarations in the WORKING-STORAGE section of the application program, immediately before PROCEDURE DIVISION. All host variable declarations must precede the DECLARE CURSOR statement in the application program.
Back to top
View user's profile Send private message
srrao_kilari

New User


Joined: 28 Nov 2005
Posts: 12
Location: New Delhi

PostPosted: Tue Dec 06, 2005 5:55 pm
Reply with quote

If u declare the Cursor in procedure division, make sure that it comes before other commands (such as OPEN, CLOSE, and FETCH) both physically and logically because DB2 precompiler parses in coding sequence and execution takes place in logical sequence.
Back to top
View user's profile Send private message
jeyakanthan

New User


Joined: 18 May 2005
Posts: 12
Location: chennai

PostPosted: Tue Dec 06, 2005 6:58 pm
Reply with quote

we should declare cursor in working-storage section because cursor is not an executable statement.

whereas in procedure division action statements should be there.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Is SQLCODE -811 possible while fetchi... DB2 1
No new posts Restart logic by using cursor name in... DB2 1
No new posts Seeking Resolution for SQKCODE -991 o... DB2 2
No new posts Multiple rows within Cursor when Coun... DB2 14
No new posts Dynamic cursor name in Cobol program COBOL Programming 1
Search our Forums:

Back to Top