Splitting one input record into multiple output records

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
datastageuser
Participant
Posts: 4
Joined: Mon Jul 28, 2003 6:52 am

Splitting one input record into multiple output records

Post by datastageuser »

I have an input record with the format:
(a, b ,c ,d ,tax1, value1 ,anothervalue1, tax2, value2, anothervalue2)
Datatype of tax1 and tax2 is tax, value1 and value2 is value, anothervalue1 and anothervalue2 is anothervalue.

My output record looks like:
(tax, value, anothervalue) - So output record is a subset of the input record.

How can I use the transformer to create 2 output records:
tax1, value1, anothervalue1
tax2 ,value2 a,nothervalue2

The problem I am having is that I am not able to map both (tax1,value1,anothervalue1) and (tax2,value2,anothervalue2) from the input file to the output file (tax,value,anothervalue).

So basically from a 1 record input file I need 2 records in the output file and all the fields in both output records are in the single record of the input file.

Any suggestions would be helpful.

Regards.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Since you neglected to state your release, here's a pre 6.0 solution:

If you have 0, 1 or 2 output rows, simply have your transformer output to two sequential text files, a and b. Put a constraint on the output link to 'a' where you have values for the first output row. Put a constraint on the output link to 'b' where you have values for the second output row. Put an after-job ExecSH or ExecNT command to concatenate a and be (NT command is copy a + b c, Unix command is cat a b > c.

For 6.0 later, use a link collector for the two transformer output links, then a single link to file 'c'.
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

You also have the option of splitting and merging your data before your transformer which will simplify your transformer and output code.

Create two file/database input stages pointing at the same source. The first stage retrieves tax1, value1 ,anothervalue1. The second source retrieves tax2, value2, anothervalue2. The merge stage merges them into tax, value, another values. You then have one transformer and one output from your job.
fred
Participant
Posts: 3
Joined: Tue Aug 12, 2003 11:19 am

Thanks

Post by fred »

Thanks guys for the suggestions. It was helpful.
aaronej
Participant
Posts: 31
Joined: Mon Aug 18, 2003 9:25 am

V7.0

Post by aaronej »

Version 7.0 has a rowmerger stage and a rowspliter stage, these should accomplish this nicely.

Aaron
Post Reply