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
 

 

Not able to declare CURSOR in Procedure division

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
mahi

New User


Joined: 04 Apr 2006
Posts: 86
Location: Pune

PostPosted: Tue Sep 23, 2008 12:49 pm    Post subject: Not able to declare CURSOR in Procedure division
Reply with quote

Hi All,
I am trying to declare a cursor in the procedure division, but it is giving error.
I have declared the same cursor in the Working storage section and it is working fine.
Can any body pls tell me the reason.
Back to top
View user's profile Send private message

Krishna Velamur

New User


Joined: 22 Aug 2008
Posts: 22
Location: Hyderabad

PostPosted: Tue Sep 23, 2008 1:00 pm    Post subject:
Reply with quote

Hi Mahi,
You should be able to declare cursor in procedure division as well as working storage section. Could you please provide more details reg the error.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6967
Location: porcelain throne

PostPosted: Tue Sep 23, 2008 1:01 pm    Post subject:
Reply with quote

you probably have your open or fetch sql phyically before the cursor declaration
even though you maybe performing the declare before you perform the open.
Back to top
View user's profile Send private message
mahi

New User


Joined: 04 Apr 2006
Posts: 86
Location: Pune

PostPosted: Tue Sep 23, 2008 1:54 pm    Post subject:
Reply with quote

No.. I have the open fetch statements after the Declare only...I am getting the error CURSOR "PROD-LDCACCT" WAS NOT DECLARED
...
Back to top
View user's profile Send private message
mahi

New User


Joined: 04 Apr 2006
Posts: 86
Location: Pune

PostPosted: Tue Sep 23, 2008 1:56 pm    Post subject:
Reply with quote

hi dICK,
Sorry...
Yes ...Physically the declare statement is after the OPen statement...
How does this effects the Cursor declaration
Back to top
View user's profile Send private message
rpuhlman

New User


Joined: 11 Jun 2007
Posts: 80
Location: Columbus, Ohio

PostPosted: Tue Sep 23, 2008 3:30 pm    Post subject:
Reply with quote

Hi Mahi,

Quote:
How does this effects the Cursor declaration


Exactly as the results have shown:

Quote:
CURSOR "PROD-LDCACCT" WAS NOT DECLARED


It is not an executable statement.

As Dick indicated, the cursor declaration must be PHYSICALLY located above/before the OPEN cursor statement. Best practices are to either declare the cursor in working storage OR immediately before your open cursor statement. Just be consistent and/or follow your shop standards.

Rick
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6967
Location: porcelain throne

PostPosted: Tue Sep 23, 2008 3:38 pm    Post subject:
Reply with quote

The db2 pre-compiler builds its 'working table information' based on a first come first served.
I does not 'look ahead' or take program logic into consideration

therefore, suggest you follow Rick's advice.
Back to top
View user's profile Send private message
mahi

New User


Joined: 04 Apr 2006
Posts: 86
Location: Pune

PostPosted: Tue Sep 23, 2008 7:12 pm    Post subject:
Reply with quote

Thank You all... I have changed the code as per Dick's Suggesion & is working fine..
Thank You Dick....
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Testing rerad cursor for status with ... John F Dutcher DB2 8 Fri May 19, 2017 9:35 pm
No new posts Getting -504 Cursor Name GTT-ARTS-CUR... Robin Sulsona DB2 2 Fri Mar 17, 2017 1:43 am
No new posts Release of Adabas Cursor mohitsethi All Other Mainframe Topics 1 Mon Feb 06, 2017 8:36 pm
No new posts Calling procedure with multiple entri... steve-myers PL/I & Assembler 5 Fri Jan 27, 2017 3:33 pm
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am


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