Create a TXT File with Row Value

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
mgsteiner
Premium Member
Premium Member
Posts: 42
Joined: Wed Aug 31, 2011 2:56 am
Location: St. Gallen - CH
Contact:

Create a TXT File with Row Value

Post by mgsteiner »

Hello all,

I have a requirement to read a table, do some validations in a transformer and write a Sequential File, having as a File Name the Key field the table in the transformer.

So if I read 100 rows, I should have 100 TXT files, every file should be named with the primary key value of the table

Any idea how can i do that?

Thanks a lot in advance
Rgds
MGS
vamsi.4a6
Participant
Posts: 334
Joined: Sun Jan 22, 2012 7:06 am
Contact:

Post by vamsi.4a6 »

1)Identify the distinct Key values after validation and write the result into a textfile

2)Use execute command stage to convert the result obtained in first step into some pipe or comma delimiter output

3)use Loop activity stage for each distinct value of the key and use proper constraint to filter only one record during each iteration
mgsteiner
Premium Member
Premium Member
Posts: 42
Joined: Wed Aug 31, 2011 2:56 am
Location: St. Gallen - CH
Contact:

Post by mgsteiner »

But that is when I use different jobs.
I want to do it in the same job:

DB Stage --> Transformer --> Sequencial File (1 per row, where File Name = Row Primary Key Value)
MGS
battaliou
Participant
Posts: 155
Joined: Mon Feb 24, 2003 7:28 am
Location: London
Contact:

Post by battaliou »

A Server job will allow you to create a type 1 hashed file which would have the properties you require.
3NF: Every non-key attribute must provide a fact about the key, the whole key, and nothing but the key. So help me Codd.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or perhaps by using the Folder stage as the target. Worst case on UNIX you could create one file and then use csplit after job to bust it up. Is that included in the MKS Toolkit?
-craig

"You can never have too many knives" -- Logan Nine Fingers
mgsteiner
Premium Member
Premium Member
Posts: 42
Joined: Wed Aug 31, 2011 2:56 am
Location: St. Gallen - CH
Contact:

Post by mgsteiner »

Thanks a lot ghuys, I just split the job as following.

1.- Job to create the hash with all data
2.- setting the userstatus with the @inrownum (to get the total rows)
3.- do a loop till @inrownum
4.- create a filename in every step
5.- loading the data for that filename=primary key

Thanks alot in advance
MGS
Post Reply