SQLCODE 100 with count(*) ?



IBM's flagship relational database management system

SQLCODE 100 with count(*) ?

Postby iamamainframer » Tue Oct 23, 2012 4:32 pm

SELECT COUNT(*) INTO :WS-COUNT
FROM TABLEA
WHERE ACC_N = :WS-ACC-N


if WS-ACC-N not found in TABLEA
what will be the SQLCODE of the query 0 or 100??

If SQLCODE 0 can we safely assume this query will never give SQLCODE 100??

I think SQLCODE should be 0 and yes this query will never give SQLCODE 100 .Just wanted it to get confirmed.
iamamainframer
 
Posts: 7
Joined: Sun Feb 27, 2011 11:54 am
Has thanked: 1 time
Been thanked: 0 time

Re: SQLCODE 100 with count(*) ?

 

Re: SQLCODE 100 with count(*) ?

Postby Pandora-Box » Tue Oct 23, 2012 5:59 pm

SQlcode 100 means no records found

So when WS-ACC-N is not found in TABLEA you will get Sqlcode 100 and not 0
User avatar
Pandora-Box
 
Posts: 65
Joined: Fri Feb 10, 2012 8:30 pm
Location: Mars
Has thanked: 3 times
Been thanked: 6 times

Re: SQLCODE 100 with count(*) ?

Postby dick scherrer » Tue Oct 23, 2012 8:01 pm

Hello,

if WS-ACC-N not found in TABLEA
what will be the SQLCODE of the query 0 or 100??
Is there some reason you did not simply test this?

Do so, and if there are any surprises or doubts, post what happened and what you would like us to clarify.
Hope this helps,
d.sch.
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: SQLCODE 100 with count(*) ?

Postby GuyC » Fri Oct 26, 2012 2:53 pm

select count(*) from sysibm.sysdummy1   
where IBMREQD = 'N';                   
          0                             
DSNE610I NUMBER OF ROWS DISPLAYED IS 1
I can explain it to you, but i can not understand it for you.

These users thanked the author GuyC for the post:
iamamainframer (Fri Oct 26, 2012 3:08 pm)
GuyC
 
Posts: 315
Joined: Tue Aug 11, 2009 3:23 pm
Has thanked: 1 time
Been thanked: 4 times

Re: SQLCODE 100 with count(*) ?

Postby iamamainframer » Fri Oct 26, 2012 3:08 pm

Thanks guyc .

I think SQLCODE should be 0 and yes this query will never give SQLCODE 100 .Just wanted it to get confirmed.


Thanks for confirming this.
iamamainframer
 
Posts: 7
Joined: Sun Feb 27, 2011 11:54 am
Has thanked: 1 time
Been thanked: 0 time

Re: SQLCODE 100 with count(*) ?

Postby Pandora-Box » Fri Oct 26, 2012 3:16 pm

iamamainframer,

Did you try a Spufi and execute for count(*) where you have no records meetting a condition?
User avatar
Pandora-Box
 
Posts: 65
Joined: Fri Feb 10, 2012 8:30 pm
Location: Mars
Has thanked: 3 times
Been thanked: 6 times

Re: SQLCODE 100 with count(*) ?

Postby GuyC » Fri Oct 26, 2012 3:35 pm

premkrishnan wrote:Did you try a Spufi and execute for count(*) where you have no records meetting a condition?

Spufi always returns +100 when number of lines < "MAX SELECT LINES "
it doesn't mean that 1 embedded select returns +100
I can explain it to you, but i can not understand it for you.
GuyC
 
Posts: 315
Joined: Tue Aug 11, 2009 3:23 pm
Has thanked: 1 time
Been thanked: 4 times


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post