Page 1 of 1

What will be the SQLCODE for below select query?

Posted: Mon May 26, 2014 4:43 pm
by Nitin Jain
Hi,

I was asked this question in an Interview:

What will be the SQLCODE for below select query

Code: Select all

SELECT COUNT(*) FROM EMP WHERE EMPNO=1234
and suppose row with employee number 1234 is not present in table.

Thanks,

Re: What will be the SQLCODE for below select query?

Posted: Tue May 27, 2014 11:39 pm
by Anuj Dhawan
Hello,

If you run the query in COBOL as an embedded SQL -- you'll get SQLCODE as 0, when row EMPNO=1234 is not present in the table. OTOH, if you remove COUNT then you'll get the SQLCODE as +100.

Hope this helps.

Re: What will be the SQLCODE for below select query?

Posted: Wed May 28, 2014 2:37 pm
by Nitin Jain
Thank you Anuj! :)

Re: What will be the SQLCODE for below select query?

Posted: Wed May 28, 2014 2:40 pm
by Anuj Dhawan
You're welcome and Good Luck! :)