View previous topic :: View next topic
|
Author |
Message |
anjani shanker
New User
Joined: 26 Jan 2007 Posts: 37 Location: USA
|
|
|
|
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 |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
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 |
|
|
anjani shanker
New User
Joined: 26 Jan 2007 Posts: 37 Location: USA
|
|
|
|
So hwz I am going to keep it...
EXEC SQL FETCH C1 INTO :DEPTVAL:DEPTVALIND; |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
anjani shanker
New User
Joined: 26 Jan 2007 Posts: 37 Location: USA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
anjani shanker
New User
Joined: 26 Jan 2007 Posts: 37 Location: USA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
You're welcome - good luck
d |
|
Back to top |
|
|
|