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

Question regarding Cursor..Plz Help!


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

New User


Joined: 26 Jan 2007
Posts: 37
Location: USA

PostPosted: Tue Jan 19, 2010 2:39 am
Reply with quote

Is this a valid cursor definition and valid fetch stmt?

EXEC SQL DECLARE C1 CURSOR FOR
SELECT * FROM DSN8710.DEPT
WHERE ADMRDEPT = 'A00';

EXEC SQL OPEN C1;

EXEC SQL FETCH C1 INTO :DEPTVAL; -------DEPTVAL is the group variable having all the host col defined under it, in the tabular order we need.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Jan 19, 2010 2:44 am
Reply with quote

You need 2 group variables, one for all the host variables for the cols, and one for null-indicators for all the cols. This type of cursor is not allowed at some sites!
Back to top
View user's profile Send private message
anjani shanker

New User


Joined: 26 Jan 2007
Posts: 37
Location: USA

PostPosted: Tue Jan 19, 2010 2:48 am
Reply with quote

So hwz I am going to keep it...

EXEC SQL FETCH C1 INTO :DEPTVAL:DEPTVALIND;
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jan 19, 2010 4:09 am
Reply with quote

Anjani Shanker,

i can tell you do a lot of reading.
there probably is not one manual on the planet that suggests using SELECT *.
Back to top
View user's profile Send private message
anjani shanker

New User


Joined: 26 Jan 2007
Posts: 37
Location: USA

PostPosted: Tue Jan 19, 2010 10:48 pm
Reply with quote

Thanks dbz for the suggestion, I am just trying to bring down the amount of coding to be done for one of my work. Regarding cursor with Select *, i saw one defined in the IBM manual itself and that's why i was curious to know if this really works or not and took it to you guys. Thanks Craq, for your help too!!
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Jan 19, 2010 11:00 pm
Reply with quote

Hello,

Quote:
I am just trying to bring down the amount of coding to be done for one of my work
Suggest you re-consider the priorities. . .

Firstly, the code must work correctly every time.
Second, the code shouild not waste enormous amounts of resources.
Third, the code must be understandable/maintainable by other than the author.

Meeting these often does not "bring down the amount of code". . . It is better to invest in good code than be concerned about writing the code in the fewest keystrokes. . .
Back to top
View user's profile Send private message
anjani shanker

New User


Joined: 26 Jan 2007
Posts: 37
Location: USA

PostPosted: Wed Jan 20, 2010 9:38 am
Reply with quote

Thanks D.S. for your valuable suggestions, my requirements were somewhat like, using * I considered as an option. Anyways i have it working for me now. Thanks again!!
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jan 20, 2010 10:41 am
Reply with quote

You're welcome - good luck icon_smile.gif

d
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 Question for file manager IBM Tools 7
No new posts question for Pedro TSO/ISPF 2
No new posts question on Outrec and sort #Digvijay DFSORT/ICETOOL 20
No new posts panel creation question TSO/ISPF 12
No new posts Sort w/OUTREC Question DFSORT/ICETOOL 2
Search our Forums:

Back to Top