Read date from text file and pass to next job

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
midmaxds
Premium Member
Premium Member
Posts: 71
Joined: Mon Oct 26, 2015 11:44 am

Read date from text file and pass to next job

Post by midmaxds »

Hi, I am pretty new to Datastage.
I am using version 11.3.1.

We have a requirement to read the last run date from a text file.
The last job of the sequencer writes current date and time to a file when it completes.

when the next day the sequencer starts, the first job should read this file and pass that date alone to second job.
The second job needs to pull data from table based on the date we will pass.

How can we read the date from the text file and pass it on to job 2? Thanks!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Welcome.

There are several ways but I'd probably suggest you add an Execute Command stage to the Sequence job. Execute a "cat" command on the file (which will write the contents of the file to stdout) and then you can use the StageName.$CommandOutput<1> value as the parameter for the job that needs it.

The reason for the "array notation", i.e. the <1> bit is because the command output data is technically a dynamic array which can support multiple records with a special delimiter between them. That notation means you only want the 1st entry (record) in the array.

See if that works for you. Of course, you'll need to make sure the file exists and is properly populated before you run the sequence the first time.
-craig

"You can never have too many knives" -- Logan Nine Fingers
naveenkumar.ssn
Participant
Posts: 36
Joined: Thu Dec 03, 2009 9:11 pm
Location: Malaysia

Re: Read date from text file and pass to next job

Post by naveenkumar.ssn »

you can write the content to the file with some delimiter and then read the file with execute command activity and pass it on to the next job.

Example: if you have appended the , (comma) delimter your run-date would be like 27-OCT-2015,

Read this file in execute command activity , you can give the command like

AWK -F"," '{ print $1}' Filename.txt

In the mapping of the parameter tab , read the output of the execute command activity.
Naveen Kumar
Datastage Consultant
Post Reply