sequential file name with system date and time

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
luca
Participant
Posts: 81
Joined: Wed May 14, 2003 11:34 pm

sequential file name with system date and time

Post by luca »

How can I insert the system variable @date and @time in the name of a file ? Hope it is possible.
Thanks.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Depends on where you're doing it.

In DataStage BASIC it's easy.
FileName:".":Oconv(@DATE,"DDMY":@VM:"MCN"):".":Oconv(@TIME,"MTS":@VM:"MCN")


Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
luca
Participant
Posts: 81
Joined: Wed May 14, 2003 11:34 pm

Post by luca »

Thank you for your anwers, to be more precise:
I want to do this in a job server (with a flow design)
and don't want to use a parameter (as this is not a parameter)
...
any other ideas?
luca
Participant
Posts: 81
Joined: Wed May 14, 2003 11:34 pm

Post by luca »

By the way (for ranjan), to insert a parameter value in the name of a file, the syntax is:
FILE_#parameterName#
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

luca -

I don't *believe* you can do this in a server job without leveraging a job parameter. Meaning, typically this would be set by job control and then passed in as a parameter. Or another (pre/controlling) job could generate the information and then stash it in a manner that a followup job could grab it and bring it in as a parameter. We date/time stamp filenames in this manner all the time.

Be happy to be proven wrong. [:)]

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

Post by ray.wurlod »

How about writing to a standard file name, then changing the name in an after-stage subroutine, perhaps ExecSH to execute a mv command?
Check out the man page on date, and remember that you can capture the output of a command in backquotes.
For example: mv filename filename.`date`
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Another excellent suggestion from Ray! [:D] You could even use a 'generic' script that takes the filename as a parameter and stamps it in some standard manner, which may give you a little more control and the ability to report errors more gracefully.

Don't forget you have control over the formatting of the date command, and can include the time as well. For example:

`date +%m%d%Y_%H%M%S`
`date +%Y%m%d`

-craig
mihai
Participant
Posts: 30
Joined: Thu Mar 13, 2003 5:24 am
Location: Hertfordshire

Post by mihai »

[:(]
You lucky lucky people.
DataStage on Unix (sigh)
[V]

Mihai

_________________________
desk direct:+441908448571
Post Reply