Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

SQLCODE as 100 while OPENING/CLOSING the cursor ?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
gragha

New User


Joined: 25 Jul 2006
Posts: 23

PostPosted: Mon Apr 30, 2007 11:31 pm    Post subject: SQLCODE as 100 while OPENING/CLOSING the cursor ?
Reply with quote

Hi,

Is it possible to get a SQLCODE as 100 while OPENING/CLOSING the cursor ? This is not a question for a specific cursor but a general one.

Thanks, Ragha
Back to top
View user's profile Send private message

socker_dad

Active User


Joined: 05 Dec 2006
Posts: 147
Location: Columbia, MO

PostPosted: Tue May 01, 2007 2:24 am    Post subject: Re: SQLCODE as 100 while OPENING/CLOSING the cursor ?
Reply with quote

Yes, you can get a -100 on an Open Cursor. Bear in mind that is on the actual OPEN, not the DECLARE.

This is because you have to supply some sort of key value for the cursor, regardless of whether the table entries are expected to be less than, equal to, or greater than the supplied value.

If nothing satisfies the condition, a -100 is the result.

You cannot get a -100 on a close cursor, as you are not supplying any information with which to read the table: you are simply releasing your DB2 thread.

Hope this helps.
Back to top
View user's profile Send private message
gragha

New User


Joined: 25 Jul 2006
Posts: 23

PostPosted: Tue May 01, 2007 2:29 am    Post subject: Re: SQLCODE as 100 while OPENING/CLOSING the cursor ?
Reply with quote

Hi,

I think the OPEN cursor just prepares the data for the FETCH Statement. So when there is no rows matching the values that we gave in DECLARE cursor, it will prepare the data but there will not be any value in it. Since the preparation was successfull I think it will still give a SQLCODE of 0 and while we fetch, then only it tries to retrieve the data that it prepared and since there were no data it will give an SQLCODE of 100.

If we go with what you suggest, then we can easily identify if there is data available after the OPEN CURSOR statement only and not even execute the FETCH.

I tried a condition with no matching rows and it still gave an SQLCODE of 0 while opening and 100 while fetching which looks contrary to what you said. Please let me know if I am wrong.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Tue May 01, 2007 2:32 am    Post subject:
Reply with quote

I looked around, and I can't find any indication that a +100 wil be rasied by a cursor open.....
Back to top
View user's profile Send private message
wanderer

Active User


Joined: 05 Feb 2007
Posts: 199
Location: Sri Lanka

PostPosted: Tue May 01, 2007 11:37 am    Post subject:
Reply with quote

As far as I remember, although FETCH is the one which actually gets data, if your SQL has things like Order-By etc then it is OPEN that gets the data and then prepares for subsequent FETCH. So I would think a +100 in OPEN is possible. Don't understand how a CLOSE will give +100.

Again, I haven't verified it or seen it written in a manual, so can't be 100% sure.
Back to top
View user's profile Send private message
MFRASHEED

Active User


Joined: 14 Jun 2005
Posts: 186
Location: USA

PostPosted: Tue May 01, 2007 8:05 pm    Post subject: Re: SQLCODE as 100 while OPENING/CLOSING the cursor ?
Reply with quote

Here is text from manual:

And deriving conclusion from statements in BOLD looks like +100 is not possible on OPEN.


The result table of the cursor is derived by evaluating the SELECT statement. The evaluation uses the current values of any special
| registers or PREVIOUS VALUE expressions specified in the SELECT statement and the current values of any host variables specified in the SELECT statement or the USING clause of the OPEN statement. The rows of the result table can be derived during the execution of the OPEN statement and a temporary copy of a result table can be created to hold them. They can be derived during the execution of later FETCH statements. In either case, the cursor is placed in the open state and positioned before the first row of its result table. If the table is empty the position of the cursor is effectively "after the last row." DB2 does not indicate an empty table when the OPEN statement is executed. But it does indicate that condition, on the first execution of FETCH, by returning values of +100 for SQLCODE and '02000' for SQLSTATE.


and link to manual : http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/dsnsqj10/5.77?ACTION=MATCHES&REQUEST=CURSOR&TYPE=FUZZY&SHELF=&DT=20040216135741&CASE=&searchTopic=TOPIC&searchText=TEXT&searchIndex=INDEX&rank=RANK&ScrollTOP=FIRSTHIT#FIRSTHIT
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Natural ADABAS Opening with CTS enikhilk Mainframe Jobs 0 Wed Nov 30, 2016 5:37 pm
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
This topic is locked: you cannot edit posts or make replies. Job Opening for 3 to 10 yrs exp. in I... princeaggarwal Mainframe Jobs 0 Sat Aug 20, 2016 3:17 pm
No new posts PL/I: opening file w/ dynamically det... Sam Dodgers PL/I & Assembler 6 Wed Jul 27, 2016 4:05 pm
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us