View previous topic :: View next topic
|
Author |
Message |
jamshirqureshi
New User
Joined: 13 Aug 2006 Posts: 20 Location: mumbai
|
|
|
|
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 |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Jamz,
Never tried to declare in procedure division.
I guess you could declare a dynamic cursor in procedure division |
|
Back to top |
|
|
jamshirqureshi
New User
Joined: 13 Aug 2006 Posts: 20 Location: mumbai
|
|
|
|
hi Dave,
not getting clear idear can you expand you answer
---------------
Jamz |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
|