View previous topic :: View next topic
|
Author |
Message |
HameedAli
Active User
Joined: 16 Apr 2009 Posts: 151 Location: India
|
|
|
|
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 |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
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 |
|
|
HameedAli
Active User
Joined: 16 Apr 2009 Posts: 151 Location: India
|
|
|
|
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 |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
/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... /Just out of context..off |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
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 |
|
|
|