Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

where we declare the cursor

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
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    Post subject: where we declare the cursor
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    Post subject:
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    Post subject: Re: where we declare the cursor
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    Post subject:
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    Post subject: Re: where we declare the cursor
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    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts DB2 Stored Procedure - Dynamic SQL - ... GuyC DB2 2 Wed Feb 17, 2016 5:10 pm
No new posts ISREDIT - Position Cursor on the Comm... Tarique Anwer TSO/ISPF 5 Wed Feb 03, 2016 12:44 pm
No new posts Need a cursor to achieve the below re... sandeep kumar302 DB2 10 Tue Mar 31, 2015 10:52 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us