View previous topic :: View next topic
|
Author |
Message |
prasannanjaneya chowdary
New User
Joined: 24 Feb 2005 Posts: 4 Location: pune
|
|
|
|
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 |
|
|
weejaireddy
New User
Joined: 22 Feb 2005 Posts: 2 Location: pune.india
|
|
|
|
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 |
|
|
ovreddy
Active User
Joined: 06 Dec 2004 Posts: 211 Location: Keane Inc., Minneapolis USA.
|
|
|
|
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 |
|
|
Girishm
New User
Joined: 09 Mar 2005 Posts: 35 Location: Mysore
|
|
|
|
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 |
|
|
i413678 Currently Banned Active User
Joined: 19 Feb 2005 Posts: 112 Location: chennai
|
|
|
|
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 |
|
|
|