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
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Diff b/w 'DECLARE CURSOR' in Procedure & WSS
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    Post subject:
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    Post subject:
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    Post subject: Re: Diff b/w 'DECLARE CURSOR' in Procedure & WSS
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    Post subject:
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    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 Testing rerad cursor for status with ... John F Dutcher DB2 8 Fri May 19, 2017 9:35 pm
No new posts Getting -504 Cursor Name GTT-ARTS-CUR... Robin Sulsona DB2 2 Fri Mar 17, 2017 1:43 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