Posted: Tue Nov 14, 2006 11:24 am Post subject: code for JCL and PROC needed
Members,
I want to create a JCL which will execute a PROC but in the proc we are unloading data from a DB2 table and the queries for unload are different for each day based on day name of the week.If it is run on Monday it should take EMPDAY = '1' and so on but i want the PROC to be one only.Plese let me know the code for JCL and PROC.
The sample queries are:
Code:
SELECT EMPLNO,EMPNAME,EMPDAY FROM EMPTABLE WHERE EMPDAY = '1';
SELECT EMPLNO,EMPNAME,EMPDAY FROM EMPTABLE WHERE EMPDAY = '2';
SELECT EMPLNO,EMPNAME,EMPDAY FROM EMPTABLE WHERE EMPDAY = '3';
SELECT EMPLNO,EMPNAME,EMPDAY FROM EMPTABLE WHERE EMPDAY = '4';
SELECT EMPLNO,EMPNAME,EMPDAY FROM EMPTABLE WHERE EMPDAY = '5';
SELECT EMPLNO,EMPNAME,EMPDAY FROM EMPTABLE WHERE EMPDAY = '6';
SELECT EMPLNO,EMPNAME,EMPDAY FROM EMPTABLE WHERE EMPDAY = '7';
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Tue Nov 14, 2006 11:39 am Post subject:
mfuser,
You don't need multiple sql statements. Use DAYOFWEEK function to get the current day no. The DAYOFWEEK function returns an integer in the range of 1 to 7 that represents the day of the week where 1 is Sunday and 7 is Saturday.
Check this sql
Code:
SELECT EMPLNO
,EMPNAME
,EMPDAY
FROM EMPTABLE WHERE EMPDAY = DAYOFWEEK(CURRENT DATE)
;
Many thanks to your answer and it is working fine.But if i want to code JCL and PROC instead of using the DB2 Builtin function how would the code be , i want to know how can we make use of JCL and PROC and pass the value day of the week ?
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Tue Nov 14, 2006 1:34 pm Post subject:
Quote:
i want to know how can we make use of JCL and PROC and pass the value day of the week ?
mfuser,
*sigh* JCL is just a job control language . It CanNOT do anything on it own. It is just a control language used to identify a job to an operating system and to describe the job's requirement. It is your utilities and pgms that does the data manipulation.
There are no built-in functions in JCL that will give you the day of the week. I guess you like the long route. Here is an example. This uses 1 proc and seven JCL's to run to different days.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum