sql code after FETCH

IBM's flagship relational database management system

sql code after FETCH

Postby sravani » Sun Jan 03, 2010 11:23 pm

what is the sql code after a successful FETCH
can check for SQLCODE = 100 after a FETCH statement ?
Posts: 2
Joined: Sat Dec 26, 2009 1:04 pm
Has thanked: 0 time
Been thanked: 0 time

Re: sql code after FETCH


Re: sql code after FETCH

Postby dick scherrer » Mon Jan 04, 2010 6:25 am


Depends on what you mean by a "successful" fetch.

Suggest you run a test with a cursor that you know will retrieve multiple rows and display the sqlcode after each iteration. Suggest you run another test trying to fetch rows from a cursor that would not open. And another with a valid cursor, but no matching rows.

If there is something happens that is not clear, post what happened and your doubt and someone will be able to clarify.
Hope this helps,
User avatar
dick scherrer
Global moderator
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: sql code after FETCH

Postby Anuj Dhawan » Tue Jan 05, 2010 6:59 pm

This is little loose question. The way, you post it - question makes no or very less sense.

If the question was,

I've a db2 table and "Select" is performed for row.
If sqlcode = 0 then values from row are used.
If sqlcode = +100, then program populates values.

so which select will return from db2 quicker, the sqlcode 0 with data or +100 without any data?

Answer could be - If the column is defined with null and you use IFNULL/VALUE/COALSCE on the column and retrieve the default value with sql code - which is eventually always zero.
Anuj Dhawan
Posts: 274
Joined: Mon Feb 25, 2008 3:53 am
Location: Mumbai, India
Has thanked: 6 times
Been thanked: 4 times

Return to DB2


  • Related topics
    Last post