View previous topic :: View next topic
|
Author |
Message |
nashaikh
New User
Joined: 30 Oct 2008 Posts: 3 Location: Pune, India
|
|
|
|
How can we check if the cursor is open before going for a fetch or close? One way is to set a flag if the cursor open fails and check this flag. What are the other options? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
How can we check if the cursor is open before going for a fetch or close? One way is to set a flag if the cursor open fails and check this flag. What are the other options? |
write better code - if the open cursor fails no reason to proceed further |
|
Back to top |
|
|
senthilnathanj
New User
Joined: 31 Jul 2007 Posts: 47 Location: chennai
|
|
|
|
hi,
Quote: |
How can we check if the cursor is open before going for a fetch or close? One way is to set a flag if the cursor open fails and check this flag. What are the other options? |
write code - if the open cursor fails check the SQLCODE.
if SQLCODE = 0 THEN print the message OPEN CURSOR SUCCESSFULLY...
your program is written in COBOL means use DISPLAY statement or PLI means use PUT SKIP LIST statement..
now, u can try and let me know if you have any concerns.. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
How can we check if the cursor is open before going for a fetch or close? One way is to set a flag if the cursor open fails and check this flag. What are the other options? |
Suggest you completely leave this line of thought behind.
When you issue the cursor open, immediately check to see if it was successful. If it was not, terminate the run with an appropriate message and show the error that was given by db2.
There is no need to set and check some indicator later if the open fails. |
|
Back to top |
|
|
nashaikh
New User
Joined: 30 Oct 2008 Posts: 3 Location: Pune, India
|
|
|
|
thanks all for the suggestions. i got what i needed. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
nashaikh wrote: |
i got what i needed. |
If you share the solution used, it would be good for others who are looking solution for similar kind of problem . . . |
|
Back to top |
|
|
|