Page 1 of 1

Create a TXT File with Row Value

Posted: Mon Oct 15, 2012 2:44 am
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

Posted: Mon Oct 15, 2012 3:05 am
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

Posted: Mon Oct 15, 2012 4:49 am
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)

Posted: Mon Oct 15, 2012 5:03 am
by battaliou
A Server job will allow you to create a type 1 hashed file which would have the properties you require.

Posted: Mon Oct 15, 2012 7:01 am
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?

Posted: Mon Oct 15, 2012 2:24 pm
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