Pass yesterday's date as parameter

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
opdas
Participant
Posts: 115
Joined: Wed Feb 01, 2006 7:25 am

Pass yesterday's date as parameter

Post by opdas »

Hi,

I have a situation where I have to extract data from a oracle table which are generated daily with name as "table_mmddyyyy" so if I can pass yesterday's date as parameter in the extarction job then I can select the table which is created yesterday.

How can I pass that automatically at run time?

Pl help.

Regards
Om
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If you're passing a parameter to the job you have to pass it from somewhere - perhaps a job sequence, perhaps a shell script. It's there that you generate yesterday's date. In a job sequence a suitable expression is

Code: Select all

Oconv(@DATE - 1, "D-YMD[4,2,2]")
(Adjust the specification to suit requirements.)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
opdas
Participant
Posts: 115
Joined: Wed Feb 01, 2006 7:25 am

Post by opdas »

ray.wurlod wrote:If you're passing a parameter to the job you have to pass it from somewhere - perhaps a job sequence, perhaps a shell script. It's there that you generate yesterday's date. In a job sequence a suitable expression is

Code: Select all

Oconv(@DATE - 1, "D-YMD[4,2,2]")
(Adjust the specification to suit requirements.)
Thanks for the prompt reply ray,
I have a shell script written which can generate yesterday's date in the format I want. How do I pass it in parameter?

Regards
Om
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

dsjob -server <host> -user <userID> -password <passwd> -run -jobstatus -param name=value <projectname> <job>
You can have as many -param name=value options as needed.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Create a parameter for table name.
In Job Sequence Value expression where parameters value is passed, use TAB:Oconv(Date()-1,"DMDY[2,2,4]")
Where TAB is the parameter for the table name.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Oops a late reply :oops:
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
opdas
Participant
Posts: 115
Joined: Wed Feb 01, 2006 7:25 am

Post by opdas »

kumar_s wrote:Oops a late reply :oops:
Hi Kumar,
Your solution looked intresting, but geting the following date format but I dont want the space in between.

"03 05 2006" I want>> "03052006"

Regards
Om
ameyvaidya
Charter Member
Charter Member
Posts: 166
Joined: Wed Mar 16, 2005 6:52 am
Location: Mumbai, India

Post by ameyvaidya »

Hi Om,

Wrap Kumar's Function call in ereplace like:

Code: Select all

EREPLACE(Oconv(Date()-1,"DMDY[2,2,4]"),' ','')
to replace all spaces to Empty Strings.
Amey Vaidya<i>
I am rarely happier than when spending an entire day programming my computer to perform automatically a task that it would otherwise take me a good ten seconds to do by hand.</i>
<i>- Douglas Adams</i>
opdas
Participant
Posts: 115
Joined: Wed Feb 01, 2006 7:25 am

Post by opdas »

ameyvaidya wrote:Hi Om,

Wrap Kumar's Function call in ereplace like:

Code: Select all

EREPLACE(Oconv(Date()-1,"DMDY[2,2,4]"),' ','')
to replace all spaces to Empty Strings.
Done...
Thanks a Lot !
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

More efficient is

Code: Select all

Oconv(@DATE-1, "D-YMD[4,2,2]" : @VM : "MCN")
(I assume this expression is in a job sequence; Oconv() is not available in parallel jobs but is available in job sequences.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply