Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Execute a Step/Query based on conditions

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Execute a Step/Query based on conditions
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    Post subject:
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    Post subject: Reply to: Execute a Step/Query based on conditions
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    Post subject:
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: 8620
Location: Back in jolly old England

PostPosted: Tue Nov 17, 2009 12:36 pm    Post subject:
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

Site Director


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

PostPosted: Tue Nov 17, 2009 8:32 pm    Post subject:
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

Senior Member


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

PostPosted: Tue Nov 17, 2009 8:47 pm    Post subject:
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: 1703
Location: Australia

PostPosted: Wed Nov 18, 2009 3:33 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts query to fetch record which has only ... maxsubrat DB2 12 Mon Dec 11, 2017 5:03 pm
No new posts How to query MAXGENS of an existing P... Chuchulo Hatyzak JCL & VSAM 4 Wed Nov 22, 2017 10:23 pm
No new posts Native SQL Query kishpra DB2 1 Wed Nov 22, 2017 8:38 pm
No new posts Split files upto certain limit based ... bubbu75 DFSORT/ICETOOL 5 Tue Nov 14, 2017 11:11 pm
No new posts Query on IEFBR14 with GDG Ashishpanpaliya JCL & VSAM 4 Tue Nov 07, 2017 8:34 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us