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
 

 

Logic behind that declaring cursor in procedure division

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
jamshirqureshi

New User


Joined: 13 Aug 2006
Posts: 20
Location: mumbai

PostPosted: Wed Jan 17, 2007 6:54 am    Post subject: Logic behind that declaring cursor in procedure division
Reply with quote

Hi All,

Can anybody clear my doubt

we can declare cursor in procedure division as well as working storage section but declare cursor is not executebale anybody can tell me what is the logic behind that declaring cursor in procedure division and working storage section.

Thannks in advance

Jamz
Back to top
View user's profile Send private message

DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Wed Jan 17, 2007 7:25 am    Post subject: Re: declaring cursor
Reply with quote

Jamz,

Never tried to declare in procedure division.

I guess you could declare a dynamic cursor in procedure division
Back to top
View user's profile Send private message
jamshirqureshi

New User


Joined: 13 Aug 2006
Posts: 20
Location: mumbai

PostPosted: Wed Jan 17, 2007 7:47 am    Post subject: can you explain more
Reply with quote

hi Dave,

not getting clear idear can you expand you answer

---------------
Jamz
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Wed Jan 17, 2007 7:55 am    Post subject: Re: declaring cursor
Reply with quote

As you can build dynamic SQL in the procedure division, you can probably declare dynamic cursor in procedure division. meaning, at compile time you do not know what the cursor will look like, so you construct it in working storage variable and then execute it.

Read about dynamic SQL in the DB2 manual. interesting stuff.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Wed Jan 17, 2007 2:26 pm    Post subject: Re: Logic behind that declaring cursor in procedure division
Reply with quote

Hi Jamz,
jamshirqureshi wrote:
we can declare cursor in procedure division as well as working storage section but declare cursor is not executebale anybody can tell me what is the logic behind that declaring cursor in procedure division and working storage section.
A static cursor needs to be declared before it is opened. The DB2 preprocesser needs to see it before it generates the code for accessing it. You are right, the declaration generates no executable code in itself so it is usually placed in the data division, that helps keep the procedure division cleaner and easier to see the logic flow.

I hope that helps,

Bill
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 -> DB2 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 Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts Access SQLCA fields inside a stored p... gangapd DB2 4 Thu Oct 27, 2016 10:20 am
No new posts Wildcard logic in COBOL dudenithy COBOL Programming 13 Thu Sep 01, 2016 7:36 pm
No new posts Is possible to call subprogram from c... cmsmoon COBOL Programming 3 Fri Aug 05, 2016 6:46 pm


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