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

Not able to declare CURSOR in Procedure division


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mahi

New User


Joined: 04 Apr 2006
Posts: 86
Location: Hyderabad

PostPosted: Tue Sep 23, 2008 12:49 pm
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
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: 6966
Location: porcelain throne

PostPosted: Tue Sep 23, 2008 1:01 pm
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: Hyderabad

PostPosted: Tue Sep 23, 2008 1:54 pm
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: Hyderabad

PostPosted: Tue Sep 23, 2008 1:56 pm
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
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: 6966
Location: porcelain throne

PostPosted: Tue Sep 23, 2008 3:38 pm
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: Hyderabad

PostPosted: Tue Sep 23, 2008 7:12 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Invoke stored procedure via batch JCL. DB2 2
No new posts Calling COBOL DB2 program from a COBO... COBOL Programming 2
No new posts Cond parameter and Rc code of a proce... JCL & VSAM 5
This topic is locked: you cannot edit posts or make replies. Internal Autonomous Stored Procedure ... DB2 6
No new posts Arithmetic division using Syncsort SYNCSORT 6
Search our Forums:

Back to Top