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

Logic behind that declaring cursor in procedure division


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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
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
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: 3156
Location: Tucson AZ

PostPosted: Wed Jan 17, 2007 2:26 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Finding faulty logic Subscript out of... COBOL Programming 5
No new posts Invoke stored procedure via batch JCL. DB2 2
This topic is locked: you cannot edit posts or make replies. Need assistance in job scheduling logic. Mainframe Interview Questions 2
No new posts Calling COBOL DB2 program from a COBO... COBOL Programming 2
No new posts Rexx Logic error while adding seperat... CLIST & REXX 3
Search our Forums:

Back to Top