View previous topic :: View next topic
|
Author |
Message |
baljinders
New User
Joined: 21 Aug 2006 Posts: 72
|
|
|
|
Hi,
I have a db2 table having column COL1 of datatype CHAR(01) that can store either a 'Y' or 'N'.
I want to read the value of this column using JCL in step01 and if the value is 'Y', it will allow step02 to execute. If value is 'N', step02 would be bypassed.
How can i achieve this using JCL?
Thanks |
|
Back to top |
|
|
technut
New User
Joined: 27 Dec 2007 Posts: 73 Location: India
|
|
|
|
I am just writing an idea that came to my mind first. There might be other better ways, but this one should work.
Just the algorithm here,
STEP0A. Write a step to read from the table into a file by giving the SQL instream.
STEP0B. The output of STEP0A is passed to STEP0B. Here you INCLUDE records with the first column as 'Y' using SORT.
STEP0C: You check the existence of data inside the output file of STEP0B using pgm=T60130. If RC=0, then it means data is present in the file and you allow STEP02 to execute, else flush the step. This can be done thru IF ELSE logic in JCL. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
usually processes that depend on database values are controlled inside the program ...
if some_database_value is ... then
some preocess
else
some other process
I guess that a yes/no switch like in this case is the consequence of the success/failure of some previous process/program/job
why not investigate how to do it with a scheduler ???
or if this way of proceeding is a standard practice of Your organization
the fastest would be to write a small program ( generalized of course )
to match some_table/some_column_name/some_value and return the appropriate return code to be checked in later steps
the easiest way would be a small REXX script, quick, effective |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
please avoid using local jargon/program names
t60130 certainly is not a program generally available,
suggesting it' s use ids just a waste of time for everybody |
|
Back to top |
|
|
technut
New User
Joined: 27 Dec 2007 Posts: 73 Location: India
|
|
|
|
OK. I should have mentioned that...I was not sure of that either! Well the intention to help was genuine.. sorry if somebody's time was wasted..
@Baljinders - Instead of T60130, you may use some locally available program available in your end to check existense of data in a file. The IBM utility IEBPTPCH could be used as well. |
|
Back to top |
|
|
baljinders
New User
Joined: 21 Aug 2006 Posts: 72
|
|
|
|
Quote: |
the easiest way would be a small REXX script, quick, effective |
Can you help me write a rexx routine? I learned REXX after i read your post and so far have been able to 1)connect to DB2 2)execute the sql and 3) disconnect from DB2
I now want to generate a return code based on the value selected from the sql in # 2 above. As i mentioned before, if the value is 'Y', the subsequent step in JCL to execute. If the selected value from REXX routine is 'N', the subsequent step would be bypassed.
Can you please share some code snippet similar to one i am looking for?
Thx |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Quote: |
so far have been able to 1)connect to DB2 2)execute the sql and 3) disconnect from DB2
I now want to generate a return code based on the value selected from the sql in # 2 above. |
Post your REXX? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
Back to top |
|
|
baljinders
New User
Joined: 21 Aug 2006 Posts: 72
|
|
|
|
I am making some progress here.
I am running the rexx routine using JCL. Through JCL parm i would like to pass in the variable value for SQL to execute. For example, I would like to pass the table_name. Here's how i have written the JCL and REXX
//SYSTSIN DD *
ISPSTART CMD(A,TABLE1)
in rexx
PARSE ARG TBLNAME
.
.
.
(SELECT MAX(DATE) FROM ' || TBLNAME......
But I am not able to run it successfully as i am getting the following error -
PREPARE S01 FAILED.
-514
SQLCODE FOR OPEN CURSOR C01 FAILED.
SQLCODE FOR CLOSE CURSOR C01 FAILED
Please suggest a remedy |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
What was the sqlcode of the prepare? The -514 is because the process tried to use a cursor that was not prepared. . . |
|
Back to top |
|
|
|