Page 1 of 1

SQLCODE 100 with count(*) ?

PostPosted: Tue Oct 23, 2012 4:32 pm
by iamamainframer
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.

Re: SQLCODE 100 with count(*) ?

PostPosted: Tue Oct 23, 2012 5:59 pm
by Pandora-Box
SQlcode 100 means no records found

So when WS-ACC-N is not found in TABLEA you will get Sqlcode 100 and not 0

Re: SQLCODE 100 with count(*) ?

PostPosted: Tue Oct 23, 2012 8:01 pm
by dick scherrer
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.

Re: SQLCODE 100 with count(*) ?

PostPosted: Fri Oct 26, 2012 2:53 pm
by GuyC
select count(*) from sysibm.sysdummy1   
where IBMREQD = 'N';                   
          0                             
DSNE610I NUMBER OF ROWS DISPLAYED IS 1

Re: SQLCODE 100 with count(*) ?

PostPosted: Fri Oct 26, 2012 3:08 pm
by iamamainframer
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.

Re: SQLCODE 100 with count(*) ?

PostPosted: Fri Oct 26, 2012 3:16 pm
by Pandora-Box
iamamainframer,

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

Re: SQLCODE 100 with count(*) ?

PostPosted: Fri Oct 26, 2012 3:35 pm
by GuyC
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