View previous topic :: View next topic |
Author |
Message |
nadh Intermediate
Joined: 08 Oct 2004 Posts: 192 Topics: 89
|
Posted: Tue Jul 19, 2005 7:54 am Post subject: declaring cursor |
|
|
Hi,
Normal practice to declare cursors is in working storage section. Is it correct if we declare in procedure division itself? Can we declare in linkage section?
Pls. let me know.
thanks
nadh |
|
Back to top |
|
 |
schintala Beginner
Joined: 18 May 2005 Posts: 108 Topics: 31 Location: USA
|
Posted: Tue Jul 19, 2005 8:00 am Post subject: |
|
|
You can declare the cursor either in Working storage or procedure division. It doesn't matter. I don't think anybody declares cursor in linkage section. |
|
Back to top |
|
 |
nadh Intermediate
Joined: 08 Oct 2004 Posts: 192 Topics: 89
|
Posted: Tue Jul 19, 2005 8:38 am Post subject: |
|
|
Hi
What is the diff. declaring in procedure division to working storage.
nadh |
|
Back to top |
|
 |
schintala Beginner
Joined: 18 May 2005 Posts: 108 Topics: 31 Location: USA
|
Posted: Tue Jul 19, 2005 8:54 am Post subject: |
|
|
no difference. |
|
Back to top |
|
 |
hisabarish Beginner
Joined: 21 Jun 2005 Posts: 38 Topics: 11
|
Posted: Wed Jul 20, 2005 12:58 am Post subject: |
|
|
You have a difference, But it is a marginal one.
Declaring in the working storage section.
System will reserve the memory for the cursor while u creating cursor in w-s-s.
Declaring in the procedure division
But here it is reserve the memory when executing the cursor
Procedure division is only for executing part not for declaring area. _________________ Sabari
Madras |
|
Back to top |
|
 |
Manas Biswal Intermediate

Joined: 29 Nov 2002 Posts: 382 Topics: 27 Location: Chennai, India
|
Posted: Wed Jul 20, 2005 2:40 pm Post subject: |
|
|
hisabarish,
What is in a cursor to reserve memory for? Memory is allocated for host variables and DCLGENs in working storage.
Regards,
Manas _________________ There is no path to peace. Peace is the path.
- Mahatma Gandhi (1869-1948) |
|
Back to top |
|
 |
CZerfas Intermediate
Joined: 31 Jan 2003 Posts: 211 Topics: 8
|
Posted: Thu Jul 21, 2005 6:00 am Post subject: |
|
|
The DECLARE CURSOR statement is used by the DB2 precompiler only. Therefore it doesn't matter, where you put it in your coding, as long as this sentence is physically placed before any referencing statement (i.e. OPEN or FETCH). Therefore it is a good practice to DECLARE a CURSOR in the Working Storage section.
If you look at the source listing after the DB2 precompiler has done it's work, you see all SQL statements commented out and replaced by calls to the DB2 language interfaces (DSNHLI, DSNCLI, etc.). This is true for all statements but the ones intended for precompiler use only, as there are the DECLARE CORSOR, the WHENEVER, the DECLARE TABLE.
regards
Christian |
|
Back to top |
|
 |
vkphani Intermediate

Joined: 05 Sep 2003 Posts: 483 Topics: 48
|
Posted: Mon Sep 12, 2005 2:06 am Post subject: |
|
|
Hi,
Could you please let me know the max length of cursor name that can be declared.
I guess it is 8.
Please confirm. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
vkphani Intermediate

Joined: 05 Sep 2003 Posts: 483 Topics: 48
|
Posted: Mon Sep 12, 2005 10:25 pm Post subject: |
|
|
Thanks for the help Kolusu. |
|
Back to top |
|
 |
|
|