To add a function to the parameter value ?

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
kaps
Participant
Posts: 452
Joined: Tue May 10, 2005 12:36 pm

To add a function to the parameter value ?

Post by kaps »

I was trying to add a date() function to a parameter in a Job Activity in a Sequencer job. In a job activity, I have a parm called FileName and I am passing a value say File1 and want to append date to that like this...

FileName = File1 : date()

Did not work. I also try to do oconv but that did not work either.
Is it not possible to add any function to value of a parm in job activity ?

Thanks
major
Premium Member
Premium Member
Posts: 167
Joined: Mon Nov 26, 2007 12:21 am

Post by major »

you can pass the current date through the sequene in whatever format you as a parameter to the job , generally , i use currentdatetimestamp(1) not sure if that is the correct trasnform

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

Post by ray.wurlod »

What you attempted seems OK. Can you tell us precisely what you did, what you expected to get, and what you actually got?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What he said. Telling us simply that it "did not work" doesn't help us help you troubleshoot the problem.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kaps
Participant
Posts: 452
Joined: Tue May 10, 2005 12:36 pm

Post by kaps »

I am sorry about that. I was executing a script from DataStage to rename a file by just adding a date to the end of the file name and the error I got is that the rename failed because both from and to names are same. Basically I am passing list of parms to the script from DS. 5th parm is the file name to be renamed and 6th parm is the new name for the file. This tells me that the date I have added is neglected for some reason.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What is the exact expression you used in the job parameter reference in the sequence Job activity?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kaps
Participant
Posts: 452
Joined: Tue May 10, 2005 12:36 pm

Post by kaps »

I tried the following 2 options:

1. 'filename': date()
2. 'filename': oconv(date(),"d4ymd")

Thanks for your time...
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

1. will pass a parameter to the job with the internal date like: filename16043

2. will pass a parameter to the job formatted like: filename2011/12/03

The above will work fine if you are calling a job with the Job Activity stage.

More recently you said you're executing a script. Are you using the Execute Command stage?

If so, then you can put your functions into a variable in the UserVariables Activity stage. Then in the Execute Command stage, under Parameters, click the ... button and click your variable.
Choose a job you love, and you will never have to work a day in your life. - Confucius
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The conversion specification for Oconv() needs to be upper case - you may wish to get rid of the space delimiters that this gives by default.

Code: Select all

Name : Oconv(Date(), "D4YMD" : @VM : "MCN")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kaps
Participant
Posts: 452
Joined: Tue May 10, 2005 12:36 pm

Post by kaps »

Ray,

It worked. I know MCN gets only the numbers and @VM is value marker but could not understand what's happening here. Can you shed somelight ?

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

Post by ray.wurlod »

Oconv() can accept a multi-valued list of conversions, which are applied one after another.
"D4YMD" generates "2011 12 06".
"MCN" applied to that removes the non-numeric characters, yielding "20111206".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kaps
Participant
Posts: 452
Joined: Tue May 10, 2005 12:36 pm

Post by kaps »

Ray
Thanks for the explanation. I got it now...Space delimiters were the issue. I overlooked it by thinking that atleast first 4 digits of date should have taken but apparently I am wrong.

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

Post by ray.wurlod »

You could have had hyphens with "D4-YMD" or underscores with "D4_YMD". Then you wouldn't have needed the "MCN". Possibly better also to enforce two-digits for month and day, for example "DYMD[4,2,2]". Without that, 2011112 is ambiguous.
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