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

Diff b/w 'DECLARE CURSOR' in Procedure & WSS


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
prasannanjaneya chowdary

New User


Joined: 24 Feb 2005
Posts: 4
Location: pune

PostPosted: Mon Mar 07, 2005 7:15 pm
Reply with quote

hi friends,
can we decalre cursor in procedure division as well as in working-storage section. if so(i mean in procedure division), what is advantage declaring it in procedure division over working storage section.
waiting for ur response

thank u,
prasanna
09850984180
Back to top
View user's profile Send private message
weejaireddy

New User


Joined: 22 Feb 2005
Posts: 2
Location: pune.india

PostPosted: Mon Mar 07, 2005 7:34 pm
Reply with quote

hi ,
actually u can declare cursor in procedure division or working storage section. its just an option provided by IBM..nothing more than tht as for my knowkedge.

regards,
weejai reddy.
Back to top
View user's profile Send private message
ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Mon Mar 07, 2005 7:40 pm
Reply with quote

Hi Chowdary,

I corrected the cursor spelling dont bother about it. Coming to your question. If we declare cursor in working storage section then it is called as static cursor without parameters from cobol.

If we declare cursor in procedure division then we can use COBOL variables as parameters to the cursor. See the examples for both the cases...

Eg: STATIC CURSOR

WORKING-STORAGE SECTION.
01 HV-EMPNO PIC 9(4) value 7934.
EXEC SQL
DEFINE C1 CURSOR FOR SELECT * FROM EMP WHERE EMPNO=HV-EMPNO
END-EXEC.

In the above case EMPNO is static. We cannot move a value or read a value in to empno, because it is in working storage section.

DYNAMIC CURSOR:

PROCEDURE DIVISION.
ACCEPT HV-EMPNO.
EXEC SQL
DECLARE C1 CURSOR FOR SELECT * FROM EMP WHERE EMPNO=:HV-EMPNO
END-EXEC.

In the above example we can read EMPNO from another table or file or we can take it from user. Now cursor becomes dynamic.

I hope now its clear for you. If you need more information let me know.

Bye,
Reddy.
Back to top
View user's profile Send private message
Girishm

New User


Joined: 09 Mar 2005
Posts: 35
Location: Mysore

PostPosted: Mon Mar 14, 2005 7:57 pm
Reply with quote

Hi Reddy,
The concept that "the cursor declared in Working storage is STATIC and the one declared in Procedure division is Dynamic" is wrong as per my knowledge.
Wherever you declare the cursor within the program, there is no difference. but it should be declared before trying to fetch a record from it. it can take the values from file or console...

Thanks,
Girish
Back to top
View user's profile Send private message
i413678
Currently Banned

Active User


Joined: 19 Feb 2005
Posts: 112
Location: chennai

PostPosted: Tue Mar 15, 2005 11:56 am
Reply with quote

hi,

You can code the DECLARE CURSOR statement in the working storage section or in the procedure division, as long as it appears before any other statements that refer to the cursor. Since it is a declarative statement and not an action statement, it is typically coded in the working storage section.




if any information about this let me know...................


cheers.......................


pavan
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 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 Stored procedure cpu utilization DB2 1
Search our Forums:

Back to Top