MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

declaring cursor

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
nadh
Intermediate


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Tue Jul 19, 2005 7:54 am    Post subject: declaring cursor Reply with quote

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
View user's profile Send private message Send e-mail
schintala
Beginner


Joined: 18 May 2005
Posts: 108
Topics: 31
Location: USA

PostPosted: Tue Jul 19, 2005 8:00 am    Post subject: Reply with quote

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
View user's profile Send private message
nadh
Intermediate


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Tue Jul 19, 2005 8:38 am    Post subject: Reply with quote

Hi

What is the diff. declaring in procedure division to working storage.

nadh
Back to top
View user's profile Send private message Send e-mail
schintala
Beginner


Joined: 18 May 2005
Posts: 108
Topics: 31
Location: USA

PostPosted: Tue Jul 19, 2005 8:54 am    Post subject: Reply with quote

no difference.
Back to top
View user's profile Send private message
hisabarish
Beginner


Joined: 21 Jun 2005
Posts: 38
Topics: 11

PostPosted: Wed Jul 20, 2005 12:58 am    Post subject: Reply with quote

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
View user's profile Send private message
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Wed Jul 20, 2005 2:40 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Yahoo Messenger
CZerfas
Intermediate


Joined: 31 Jan 2003
Posts: 211
Topics: 8

PostPosted: Thu Jul 21, 2005 6:00 am    Post subject: Reply with quote

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
View user's profile Send private message
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Mon Sep 12, 2005 2:06 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Sep 12, 2005 4:23 am    Post subject: Reply with quote

Quote:

Could you please let me know the max length of cursor name that can be declared.
I guess it is 8.

vkphani,

The max length of a cursor name is 18 . Check this link for limits of DB2

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNSQH11/A.0?DT=20010718164132

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Mon Sep 12, 2005 10:25 pm    Post subject: Reply with quote

Thanks for the help Kolusu.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group