Create output file names based on data in a column

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

PAULOM
Participant
Posts: 33
Joined: Thu Jul 11, 2013 2:03 am

Create output file names based on data in a column

Post by PAULOM »

Hello,

I shall want to know if it was possible to put in the name of my files of exits, the data of a column, I am understandable :

On a job, I extract from Oracle via a request SQL a table. On this table, there is a column Code_Test which possesses several values (ex: Code1, Code2, Code3). I create afterward files in the format *.csv.

My question is, it is possible to create my files for example :

Test_Code1.csv
Test_Code2.csv
Test_Code3.csv

To create so much file as there is of values different Code_Test.

Thanks a lot.

Sorry for my bad english, i'm french.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard. Bienvenue. You can use a Folder stage for this purpose.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
PAULOM
Participant
Posts: 33
Joined: Thu Jul 11, 2013 2:03 am

Post by PAULOM »

Thank you very much for your answer.

On the other hand, have you an example on Folder Stages? Because my skills in DataStage are more than limited :(

Thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Well... they are a little tricky to use. Check the Server Job Developer's Guide manual for the official description and do an exact search here for 'folder stage' to see what has been discussed here. Seem to recall one such conversation just last month...
-craig

"You can never have too many knives" -- Logan Nine Fingers
PAULOM
Participant
Posts: 33
Joined: Thu Jul 11, 2013 2:03 am

Post by PAULOM »

Yes, thank you I have already read this doc but I block on the place where it is necessary to insert the Stages Folder.

My job :

Oracle-->Transformer--->Sequentiel File Stage

Where place the Stages Folder?

Thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

It replaces the Sequential File stage as the target of the job.
-craig

"You can never have too many knives" -- Logan Nine Fingers
PAULOM
Participant
Posts: 33
Joined: Thu Jul 11, 2013 2:03 am

Post by PAULOM »

oK, It will be :

Oracle-->Transformer--->Stage Folder ?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Yes.

This is the post I referred to earlier. There are others if you search.

viewtopic.php?t=150112
-craig

"You can never have too many knives" -- Logan Nine Fingers
PAULOM
Participant
Posts: 33
Joined: Thu Jul 11, 2013 2:03 am

Post by PAULOM »

Ok thanks, it's possible de create *.csv files et not *.txt?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sure, just use the proper field delimiter - a comma in that case.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

As noted in the linked post and the docs, yes it takes a single record so if you have multiples you need to get them all concatenated together with a record delimiter between each. Do that in a stage variable and then send it to an aggregator set to 'last' before the Folder stage.

Sorry but I don't understand your second question.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You generate rows like this:

1
1 2
1 2 3
1 2 3 4

All you want to do is send one to the Folder, hence the aggregator set to 'last'.

No clue on the second thing at the moment.
-craig

"You can never have too many knives" -- Logan Nine Fingers
PAULOM
Participant
Posts: 33
Joined: Thu Jul 11, 2013 2:03 am

Post by PAULOM »

To recapitulate my job : I will do this

Oracle(SQL)-->Transformer-->AGGREGATOR-->StageFolder

it's ok?

Thanks Chulett
PAULOM
Participant
Posts: 33
Joined: Thu Jul 11, 2013 2:03 am

Post by PAULOM »

I have a problem, how I can make in my StageVariable :

file :
ColumnA;ColumnB;ColumnC
1;2;3
3;4;5
6;7;8

What I want before TheAggregator:
ColumnA
1;2;3;4;5;6;8...

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

Post by ray.wurlod »

You're getting into Routine territory now. You need to scan the existing list to determine whether the value already exists (use the Locate statement) and insert it if not.

Maintain the list as a field mark (@FM) delimited dynamic array sorted. Implement the following logic in your routine.

Code: Select all

Locate NewValue In ValuesList By "AR" Setting Location
Else
   Ins NewValue Before ValuesList<Location>
End
Ans = ValuesList
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