Page 1 of 1

How to split record

Posted: Tue Apr 17, 2007 7:37 am
by bollinenik
Hi,
My requiremnt is , I have 1 record in source file and I need to write that to target as 2 records , that means that single record needs to be split into 2 records

Example:
Input is
******* Single record
Col1 col2 col3 col4
a 1 3 4

Output:
****** 2 records
a 1 3
a 4

Like this, Pls help me how to implement in data stage.

Thanks in Advance.

Posted: Tue Apr 17, 2007 7:43 am
by DSguru2B
YOu can do it a couple of different ways.
One way would be to read the file twice using two different sequential file stages, stick a transformer after them. Choose Col1, Col2 and Col3 for the first stream and Col1 and Col4 from the second stream. You can then write it a sequential file (1 from each stream) and in after job subroutine do a cat, or stick a funnel stage and gather the records. But with the funnel stage you will have to specify a dummy column for your second stream so as to make the meta data similar.

Posted: Tue Apr 17, 2007 8:43 am
by bollinenik
Just sample I given 4 columns like that i had so many, so useing more sequential file stages is problem here, Can u tell me what is another way,
The total thing is Just we need to split record into multiple records to target.

Thanks in Advance

Posted: Tue Apr 17, 2007 8:48 am
by DSguru2B
Well then give us the complete requirement. Looking at your sample data, it tells me two things.
1)Split a record into two, and
2)First three columns in one record and first and last column in second record.
Now your telling me there are going to be multiple records :?
Please provide a full description of your requirements.

Posted: Tue Apr 17, 2007 8:54 am
by bollinenik
Thanks Guru,

In the same manner we may have more then 10 input fields and like that we need to split single record into 10 output records, The main thing we need to split record, that's all....Can any body tell me how to implement this splitting record scenario in data stage

Thanks in Advance

Posted: Tue Apr 17, 2007 8:58 am
by DSguru2B
So basically the number of splits should be dynamic. What column in the source record will tell how many records need to be created?
Can you please give two proper examples with data. How the incoming record will look like and on what basis it will be split and on what basis to decide what column goes into what record.
Need requirements man. If I am not able to provide the correct answer, others who can, need this info.

Posted: Tue Apr 17, 2007 12:16 pm
by novneet
For splitting one record into multiple record, the easiest way I can think of will be put a copy stage after reading the data, from copy stage drag the fields you want in the first record link and drag the fields for the second record link and so on for N number of records links.
After this for merging them, u need to put a funnel stage which will merge them.
The only point that you need to keep in mind that each record link coming out of the copy stage which is going to be input for the funnel should have similar meta-data.

Posted: Tue Apr 17, 2007 12:20 pm
by DSguru2B
novneet, your solution is impressive if the maximum number of splits is known. From what I understand, it needs to be dynamic.

Posted: Tue Apr 17, 2007 3:15 pm
by ray.wurlod
This looks suspiciously like a job for the Pivot stage to me.