View previous topic :: View next topic
|
Author |
Message |
Kmr.deepakcs
New User
Joined: 11 Oct 2013 Posts: 37 Location: India
|
|
|
|
I have a question which i have asked in csc interview.
what will the sqlcode of this query after execution.
select count(*) from tablename.
even there is no rows in table.
My answer: I told it will give sqlcode=100.
Please give your suggestion.....
Deepak kumar |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Did you try to execute and see what happens? |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
Code: |
---------+---------+---------+---------+---------+---------+---------+---------+
SELECT COUNT(*)
FROM QUALIFIER.TABLE
---------+---------+---------+---------+---------+---------+---------+---------+
---------+---------+---------+---------+---------+---------+---------+---------+
0
DSNE610I NUMBER OF ROWS DISPLAYED IS 1
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE614I AUTOCOMMIT IS NO; NO CHANGES COMMITTED
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE601I SQL STATEMENTS ASSUMED TO BE BETWEEN COLUMNS 1 AND 72
DSNE620I NUMBER OF SQL STATEMENTS PROCESSED IS 1
DSNE621I NUMBER OF INPUT RECORDS READ IS 2
DSNE622I NUMBER OF OUTPUT RECORDS WRITTEN IS 16
|
|
|
Back to top |
|
|
Kmr.deepakcs
New User
Joined: 11 Oct 2013 Posts: 37 Location: India
|
|
|
|
Thanks bharat. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
I believe SPUFI always gives a return code of 100 on a successful SELECT. Certainly used to. You really need to try this in batch. I cannot as we do not use DB2 here. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Nic Clouston wrote: |
I believe SPUFI always gives a return code of 100 on a successful SELECT. Certainly used to. You really need to try this in batch. I cannot as we do not use DB2 here. |
Yes, that's correct and an annoying quirk (for me) of SPUFI. I had to create a report once, derived from a DB2 Table, and I ended up using the Batch Job instead of SPUFI as having SQLCODE=+100 was another test case to capture... |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
But again SQLCODE = + 100 is clear that there is no row to process further something like equivalent to EOF |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
But in batch does SELCT COUNT(col) FROM table; return SQLCODE=+000 or SQLCODE=+100. I think +000 because the SELECT has successfully returned data (a count of 0). But, as I said, I cannot test this. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Spufi always returns +100 when number of lines are less than "MAX SELECT LINES". SPUFI fetches rows in a loop; the attempted FETCH after the last row gets SQLCODE +100 (row not found), and this is the code that SPUFI reports for the entire SELECT. You're correct Nic, in batch SQLCODE=+000 will be returned back. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Thanks, Anuj. Another piece of "working it out mentally" gives RC=0! |
|
Back to top |
|
|
Kmr.deepakcs
New User
Joined: 11 Oct 2013 Posts: 37 Location: India
|
|
|
|
thanks anuj and nic.
I thought answer is rc=0, bt i said sqlcode=100...my fault
But thanks for everyone for giving your valuable suggestions..........
Deepak kumar |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
You're welcome and Good Luck! |
|
Back to top |
|
|
|