How to check sqlerrd(3) variable..



IBM's flagship relational database management system

How to check sqlerrd(3) variable..

Postby snehal » Thu Nov 19, 2009 4:19 pm

Hi,

I want to check number of records fetched by cursor for particular where condition. I tried to check sqlerrd(3) variable after fetch command in code. But it was having value as zero.

Please let me know how to check number of records fetched by cursor.

Thanks.
Snehal.
snehal
 
Posts: 2
Joined: Mon Oct 05, 2009 3:58 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to check sqlerrd(3) variable..

Postby dick scherrer » Fri Nov 20, 2009 1:03 am

Hello and welcome to the forum,

Did the cursor open work successfully?

Was the fetch sqlcode zero? If the sqlcode is 100, sqlerrd(3) will contain zero.

As an experiment, you might add 1 to some counter to see what is accumulated.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: How to check sqlerrd(3) variable..

Postby snehal » Fri Nov 20, 2009 10:18 am

Hello Dick,

Yes the cursor was opened successfully and sqlcode for fetch is zero. I fetched the record and was able to write it in output file.
My requirement is I am reading input file having return number and part number. Use this as where condition for cursor and fetch those many records from table that are found for this condition.


I will try counter as you suggest.

Thanks
Snehal
snehal
 
Posts: 2
Joined: Mon Oct 05, 2009 3:58 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to check sqlerrd(3) variable..

Postby dick scherrer » Fri Nov 20, 2009 10:40 am

Good luck - it will be interesting to see what is happening :)

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: How to check sqlerrd(3) variable..

Postby jitender_2004bhiwani » Fri Nov 20, 2009 11:56 am

Hi,

Sqlerrd(3) will not work on single row fetch since anyway the fecth statement fetches only one row. Incase of rowset fetch, it tells the number of rows to be fetched. I think in this case, you should try sqleerd(3) on open cursor and it will tell you the number of estimated rows.
jitender_2004bhiwani
 
Posts: 10
Joined: Fri Nov 20, 2009 8:42 am
Has thanked: 0 time
Been thanked: 0 time

Re: How to check sqlerrd(3) variable..

Postby venki3 » Tue Feb 16, 2010 4:10 pm

Hi Snehal,
Could you post the answer when you tried the 'counter' option as suggested by Dick.

Thanks,
Venkateswari
venki3
 
Posts: 4
Joined: Tue Dec 22, 2009 2:10 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post