JCL and Direct SQL commands

JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...
mvtc19
Posts: 3
Joined: Tue Oct 30, 2018 2:46 am
Skillset: COBOL, DB2, JCL, SQL
Referer: Colleague

JCL and Direct SQL commands

Postby mvtc19 » Tue Oct 30, 2018 3:06 am

Hi, can you check SQL return code in JCL COND statements? I have step JOBX001 that does table updates and the following step JOBX002, to check for return code.
My goal is to check for SQL return code, so that I can execute a ROLLBACK or COMMIT depending on SQL return code, but I'm not getting the result I want. Somebody here knows how to do it?

Code: Select all

//JOBX001  EXEC DB2TTSO                                                
//*                                                                    
//DB2TTSO2.SYSTSPRT DD SYSOUT=*                                        
//DB2TTSO2.SYSPRINT DD SYSOUT=*                                        
//*                                                                    
//DB2TTSO2.SYSIN DD DATA,DLM=$$                                        
UPDATE PROD1.CUSTOMER_VWLOG                                            
  SET CUSTNBR = '0012354'                                              
 WHERE SQE_NBR = 11;                                                    
                                                                       
$$                                                                      
//*                                                                    
//*--------------------------------------------------------------------
//JOBX002  EXEC PGM=PNOTIFY,                                            
//             COND=(0,EQ,JOBX001.DB2TTSO2),                            
//             PARM='1500 *** TABLE UPDATE FAILED ***'                  
//*--------------------------------------------------------------------
 

NicC
Global moderator
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Skillset: JCL, PL/1, Rexx, Utilities and to a lesser extent (i.e. I have programmed using them) COBOL,DB2,IMS
Referer: Google
Location: Pushing up the daisies (almost)

Re: JCL and Direct SQL commands

Postby NicC » Tue Oct 30, 2018 7:45 am

Somebody here knows how to do it?

The same way everyone else does it - write a program.
JCL checks program return codes not query return codes. They are checked by the program executing the query.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic

willy jensen
Posts: 474
Joined: Thu Mar 10, 2016 5:03 pm
Skillset: assembler rexx zOS ispf racf smf
Referer: saw it in the experts foprum thought I could help here

Re: JCL and Direct SQL commands

Postby willy jensen » Tue Oct 30, 2018 3:11 pm

It depends, does the program executing the UPDATE command set a return code? In which case it should be set as the step rc too. Another method is to use i.e. SORT to scan the output dataset for a ok/nok message and set the step rc accordingly. But then we are of course talking about a program.

mvtc19
Posts: 3
Joined: Tue Oct 30, 2018 2:46 am
Skillset: COBOL, DB2, JCL, SQL
Referer: Colleague

Re: JCL and Direct SQL commands

Postby mvtc19 » Tue Oct 30, 2018 10:22 pm

Thank you, NicC and Willy Jensen. That's what I thought, it should be embedded within a program.


  • Similar Topics
    Replies
    Views
    Last post