Parameter Date and Location file Sequential file

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
DanielLippi
Participant
Posts: 3
Joined: Fri Mar 29, 2019 7:35 am

Parameter Date and Location file Sequential file

Post by DanielLippi »

Good afternoon. I needed some help.
I'm new to DataStage
I am trying to generate a CSV file through Sequential files, searching from a SQL SERVER table.

My doubt is:
1 - I generated the file in the DataStage output. Can this same file be generated on a network path? How do I do ? Do you need permission?

2 - Can I pass a date variable, to concatenate it with the filename? Al that it will be generated a new file every day. How do I pass this variable or simply concatenate the date in the name?
Ex: File1_20190329 / File1_20190330
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Welcome.

1) You can use a UNC path or worst case, FTP the file to the remote server post-creation. You can script that or use the FTP Stage.

2) Yes, create a job parameter to hold the date in whatever string format you need and include it in the file's name surrounded by hash/pound signs:

File1_#FileDate#
-craig

"You can never have too many knives" -- Logan Nine Fingers
DanielLippi
Participant
Posts: 3
Joined: Fri Mar 29, 2019 7:35 am

how to add job parameters?

Post by DanielLippi »

Thank you,

But excuse ignorance,

how do I pick up this current date in the format AAAAmmDD?

I am inside the job parameter.
I put it as String Type?
Do I put it within default value?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I would set the parameter to a string. And since you need it to reflect the current date, you'll need to set it each time the job runs which means a Sequence job will need to format that for you. And you would need to use either a Custom Routine or the User Variables Activity stage to provide that value for you. It's been far too long for me to remember all of the gory details on how to do that, exactly, hopefully someone here still using DataStage could help.

Another option that doesn't require the use of a job parameter is to write the file out with a fixed name and then rename it After Job using an O/S command. Windows (DOS) makes that a little different from the UNIX commands I'm used to but this article might help.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DanielLippi
Participant
Posts: 3
Joined: Fri Mar 29, 2019 7:35 am

Component change name or parameter

Post by DanielLippi »

The problem of renaming later, would be that the file would be generated on the client server. I believe we do not have permission.

Is there a component that I can rename? But either way it would need to be variable.

Do you know how I can load some variable, with information coming from a SQL query?

EX: select getdate () CurrentData.

How would you get this component to load a #Database # variable?

It would be the best in the world.

Like I said, I'm new to DataStage.

I create the variable, but at the default value, I can not add the date, and only appears what is actually written in this field, getting:
ex: File1_getdate () .csv

The correct one would be File1_20190402.csv
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Well, as noted, you could create the file locally then rename then transfer the file. Something to keep in mind. And you're right, you can't put any kind of function call in the parameter's value, it needs to be populated with the actual value to use.

Adding a requirement to get the date from SQL adds an unnecessary complication, taking this well out of "new to DataStage" territory. IMHO. Are you comfortable at the Windows command line? An Execute Command stage using this:

Code: Select all

echo %date:~10,4%%date:~4,2%%date:~7,2%
Would return 20190403 today, which could be passed to the job's parameter value inside a Sequence job.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply