I have a PS File LRECL 133 having records as below
--+----3----+----4----+----5----+----6----+----7----+----8----+----9----
***************************** Top of Data ******************************
XXXXX | 2S65 | AB | 2014-01-07
AAAAA | 2N15 | DC | 2014-01-07
BBBBB | CN15 | CC | 2014-01-07
***************************** Top of Data ******************************
XXXXX | 2S65 | AB | 2014-01-07
AAAAA | 2N15 | DC | 2014-01-07
BBBBB | CN15 | CC | 2014-01-07
I need to write the output file (making DB2 UPDATE query ) taking the values from the above file, sample shown below
UPDATE NEDY1.AAADM.AAT_052_UPDTCNTL
SET (DT_DB2_UPDT_DATE,DT_PART_UPDT_DT)
= ('2013-01-06','2013-01-06')
WHERE (NO_PARTNUM_PREFIX = ' XXXX' AND
NO_PART_NUM_BASE = ' YYYYY' AND
NO_PARTNUM_SUFFIX = 'ZZ');
SET (DT_DB2_UPDT_DATE,DT_PART_UPDT_DT)
= ('2013-01-06','2013-01-06')
WHERE (NO_PARTNUM_PREFIX = ' XXXX' AND
NO_PART_NUM_BASE = ' YYYYY' AND
NO_PARTNUM_SUFFIX = 'ZZ');
I am trying to do form this query in a o/p dataset using sort, we can get the hard-coded names of tables fields etc using OUTFIL
OUTFIL REMOVECC,
HEADER2=(5:'UPDATE NEDY1.AAADM.AAT_052_UPDTCNTL',/,
5:'SET (DT_DB2_UPDT_DATE,DT_PART_UPDT_DT)=')
HEADER2=(5:'UPDATE NEDY1.AAADM.AAT_052_UPDTCNTL',/,
5:'SET (DT_DB2_UPDT_DATE,DT_PART_UPDT_DT)=')
For SET part, I need to take dates from input file, deduct a year and form a query as shown in sample above.
Also, for the WHERE section, it needs to read record from input file, picks data from respective position and append to WHERE clause.
Kindly suggest on how to progress