IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Displaying SQLCODE returned by a query in SPUFI or JCL


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Saravana Manikandan

New User


Joined: 09 Aug 2011
Posts: 14
Location: India

PostPosted: Tue Jul 10, 2012 12:19 pm
Reply with quote

Hi,

I need to display the SQLCODE returned by a query executed through a SPUFI or JCL.

I need to continue a process through REXX based on the SQLCODE.

Could you pls help me with this?

Thanks!
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Tue Jul 10, 2012 12:23 pm
Reply with quote

Sorry, I'm not clear with your input.

How is your query executed? SPUFI in batch? or user-program (COBOL, REXX or any other)?

Please elaborate.
Back to top
View user's profile Send private message
Saravana Manikandan

New User


Joined: 09 Aug 2011
Posts: 14
Location: India

PostPosted: Tue Jul 10, 2012 12:26 pm
Reply with quote

Hi Gnana Sekaran,

I am invoking a DB2 query through JCL. I need the SQLCODE returned by the query in some variable.

Would it be possible to get in the SELECT clause?
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Tue Jul 10, 2012 12:38 pm
Reply with quote

DSNTEP* in TSO batch?

What type of DML operation you do?
Quote:
Would it be possible to get in the SELECT clause?

DB2 SELECT query?

Please post some lines of JCL step/DB2 query to understand what you're trying to do.
Back to top
View user's profile Send private message
Saravana Manikandan

New User


Joined: 09 Aug 2011
Posts: 14
Location: India

PostPosted: Tue Jul 10, 2012 12:51 pm
Reply with quote

Yes, its a DSNSTEP in TSO batch and its a SELECT query.

SELECT FIELD1 FROM TABLE1
WHERE FIELD2 = "VALUE2";

I would need the SQLCODE returned by the above query.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Tue Jul 10, 2012 1:22 pm
Reply with quote

Assuming that you're catching SYSPRINT in a data set, you may need to parse (in next step) SYSPRINT data set which holds DB2 statement results.

If you see the messages like below, you can interpret SQLCODE as 0 or +100 based on number of rows returned. And, STEP' RC would be Zero.
Code:
0SUCCESSFUL RETRIEVAL OF          0 ROW(S) 

or
Code:
0SUCCESSFUL RETRIEVAL OF          1 ROW(S)

If there is an error like below, read SQLCODE from the same line. And, STEP' RC would be 8 or higher depending on severity.
Code:
DSNT408I SQLCODE = -199, ERROR:...

Finally, you may need to consider RC=4 which might be of warnings.
Back to top
View user's profile Send private message
Saravana Manikandan

New User


Joined: 09 Aug 2011
Posts: 14
Location: India

PostPosted: Tue Jul 10, 2012 2:15 pm
Reply with quote

This will not solve my purpose when the query did not fetch any rows.

I would need a SQLCODE +100 in that case but it gives
"0SUCCESSFUL RETRIEVAL OF 0 ROW(S) "

Any suggestions to handle this?
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Tue Jul 10, 2012 3:00 pm
Reply with quote

Quote:
I would need a SQLCODE +100 in that case but it gives
"0SUCCESSFUL RETRIEVAL OF 0 ROW(S) "

This is how DSNTEP* works, I think. If 0 Rows returned, you need to assume that SQLCODE as +100

Someone here may offer you better suggestions if you explain how this requirement is originated.
Back to top
View user's profile Send private message
Saravana Manikandan

New User


Joined: 09 Aug 2011
Posts: 14
Location: India

PostPosted: Tue Jul 10, 2012 3:18 pm
Reply with quote

Thanks a lot for the suggestions!
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Jul 10, 2012 9:33 pm
Reply with quote

Hello,

Quote:
Someone here may offer you better suggestions if you explain how this requirement is originated.
If you post why someone believes this approach is needed and how it came about, someone may have a suggestion. . .
Back to top
View user's profile Send private message
Peter Nancollis

New User


Joined: 15 Mar 2011
Posts: 47
Location: UK

PostPosted: Wed Jul 11, 2012 6:04 am
Reply with quote

write some code ?
then you have control and can do what you like with the sqlcode [and in batch the condcode] .... sorry if this is sucking eggs!
Back to top
View user's profile Send private message
Heeraj

New User


Joined: 07 Dec 2010
Posts: 16
Location: Bangalore

PostPosted: Wed Jul 11, 2012 11:24 am
Reply with quote

If you need to continue "A PROCESS through REXX based on SQL CODE", I think you can read the SYSPRINT dataset in that REXX before you do your process, if you find a record
0SUCCESSFUL RETRIEVAL OF 0 ROW(S)
consider the SQL code as +100.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts DELETE SPUFI DB2 1
No new posts Adding QMF and SPUFI to the ISPF menu DB2 20
No new posts RC query -Time column CA Products 3
No new posts IBM OnDemand Folders displaying to al... IBM Tools 6
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top