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 Getting -504 Cursor Name GTT-ARTS-CUR... Robin Sulsona DB2 2 Fri Mar 17, 2017 1:43 am
No new posts Need help in building a logic Benchwarmer All Other Mainframe Topics 4 Wed Feb 22, 2017 2:49 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