Page 1 of 1

sql code after FETCH

PostPosted: Sun Jan 03, 2010 11:23 pm
by sravani
what is the sql code after a successful FETCH
can check for SQLCODE = 100 after a FETCH statement ?

Re: sql code after FETCH

PostPosted: Mon Jan 04, 2010 6:25 am
by dick scherrer
Hello,

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.

Re: sql code after FETCH

PostPosted: Tue Jan 05, 2010 6:59 pm
by Anuj Dhawan
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.