Page 1 of 1

To add a function to the parameter value ?

Posted: Fri Dec 02, 2011 11:14 pm
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

Posted: Sat Dec 03, 2011 1:22 am
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

Posted: Sat Dec 03, 2011 4:01 am
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?

Posted: Sat Dec 03, 2011 6:58 am
by chulett
What he said. Telling us simply that it "did not work" doesn't help us help you troubleshoot the problem.

Posted: Sat Dec 03, 2011 1:59 pm
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.

Posted: Sat Dec 03, 2011 3:49 pm
by ray.wurlod
What is the exact expression you used in the job parameter reference in the sequence Job activity?

Posted: Sat Dec 03, 2011 4:37 pm
by kaps
I tried the following 2 options:

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

Thanks for your time...

Posted: Sat Dec 03, 2011 10:40 pm
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.

Posted: Sun Dec 04, 2011 12:01 pm
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")

Posted: Mon Dec 05, 2011 11:58 am
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

Posted: Mon Dec 05, 2011 3:10 pm
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".

Posted: Mon Dec 05, 2011 10:52 pm
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...

Posted: Tue Dec 06, 2011 1:39 am
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.