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

Execute a Step/Query based on conditions


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Tue Nov 17, 2009 11:47 am
Reply with quote

Hi

I have to execute a Query in JCL based on the output of the first Query. I have to execute either one of the queries.
    I execute Query A, answer may be 1 or 2
    If 1 I execute Query I
    If 2, I execute Query II

How can I do it in JCL?
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Tue Nov 17, 2009 11:55 am
Reply with quote

You can run an SQL query by executing program IKJEFT.. but if you want to run or not run the next step, you can only test for a previous return code or an abend condition. You can't check for the result of the previous query.
Back to top
View user's profile Send private message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Tue Nov 17, 2009 12:14 pm
Reply with quote

I'm thinking like execute the first query, I may get the value as 1 or 2 in the unload dataset of first query from Step 1.

Use a sort card to check the value in the dataset equal to 1 or 2?

The thing, I'm not sure of is, how I execute a step based on the values from dataset, how I instruct JCL to perform or not to perform a step based on value 1 or 2.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Tue Nov 17, 2009 12:32 pm
Reply with quote

As I said, JCL can conditionally execute steps based on return codes; not values in data sets. Someone may have a workaround by getting fancy with REXX, but basically, check the MVS JCL manual.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Nov 17, 2009 12:36 pm
Reply with quote

Yet again we probably only have half the story.

Why not let us know what the first query does, from what you have said there could be a few imaginable scenarios, like it will create one dataset as output from a choice of two datasets, which is what I take as an underlying meaning to your post, but I may be wrong, but that is because you have not given enough information.
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 Nov 17, 2009 8:32 pm
Reply with quote

Hello,

Are you a programmer?

If yes, suggest you write a small program that executes the first query (A), looks at what is returned and then executes either Query1 or Query2 depending on what is returned from A.

One step of jcl, no returncode issues, no complexity. Unfortunately, it would take a bit of code. . .
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue Nov 17, 2009 8:47 pm
Reply with quote

/Just out of context..on
dick scherrer wrote:
Are you a programmer?
Taking a decision to start my career as Analyst Programmer does not seem any wrong now... icon_smile.gif/Just out of context..off
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Wed Nov 18, 2009 3:33 am
Reply with quote

Hi,

I'm not sure what the output from query A looks like, so you may be able to adapt the following :
Code:
//SEARCH1  EXEC PGM=ISRSUPC,PARM=(SRCHCMP,'ANYC')         
//NEWDD    DD DSN=INPUT-FILE                             
//OUTDD    DD SYSOUT=*                                   
//SYSIN    DD *                                           
    SRCHFOR  '1',01:01                                   
/*                                                       
//SEARCH2  EXEC PGM=ISRSUPC,PARM=(SRCHCMP,'ANYC')         
//NEWDD    DD DSN=INPUT-FILE                             
//OUTDD    DD SYSOUT=*                                   
//SYSIN    DD *                                           
    SRCHFOR  '2',01:01                                   
/*                                                       
//CHECK01  IF (SEARCH1.RUN)                               
//         &  (SEARCH1.RC = 1) THEN                       
//QUERY1   EXEC PGM=QUERY1                               
//CHECK01  ENDIF                                         
//*                                                       
//CHECK02  IF (SEARCH2.RUN)                               
//         &  (SEARCH2.RC = 1) THEN                       
//QUERY2   EXEC PGM=QUERY2                               
//CHECK02  ENDIF                                         



Gerry
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Execute secondary panel of sdsf with ... CLIST & REXX 1
No new posts How to load to DB2 with column level ... DB2 6
No new posts RC query -Time column CA Products 3
No new posts Return codes-Normal & Abnormal te... JCL & VSAM 7
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top