Header, Detail design issue

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
lfong
Premium Member
Premium Member
Posts: 42
Joined: Fri Sep 09, 2005 7:48 am

Header, Detail design issue

Post by lfong »

I have an input file with a header and 3 types of detail records.
I have split the header and 3 detail records using a filter stage, then into transforms. I need to get the date from the header record in the 3 transformed detail records.
What would be the best way to do this?

Thanks
boxtoby
Premium Member
Premium Member
Posts: 138
Joined: Mon Mar 13, 2006 5:11 pm
Location: UK

Post by boxtoby »

Try using a Stage Variable to hold the Header Date and in the derivation check for @INROWNUM = 1 or record type of Header so you only update the Stage Variable once.

The Stage Variable can then be used to populate the column in the detail records.

You may also need to control the parallel processing in that the Header may be handled by one node and therefore detail records being handled by the other nodes may not see it. Might have to force sequential processing in to the first transformer to get the date and the do the split in a subsequent transformer.
Bob Oxtoby
mhester
Participant
Posts: 622
Joined: Tue Mar 04, 2003 5:26 am
Location: Phoenix, AZ
Contact:

Post by mhester »

If the header and 3 detail have the same key you could do a join or merge or even a simple lookup to handle this situation.

I would refrain from using stage variables and messing with what node is processing what record etc... not a good way to handle the logic.

You could load the headers into a lookup file set, sequential file or data set and then stream your detail rows and join on the headers and grab what you need.

Also, the filter stage is not as efficient as the transformer stage for doing things like splitting into various output streams.
lfong
Premium Member
Premium Member
Posts: 42
Joined: Fri Sep 09, 2005 7:48 am

Post by lfong »

Mhester, I have to use either a filter or switch because the header and 3 detail records each have their own definition.
Boxtoby, aren't stage variables local to the transform being used? I have 4 transforms after the filter.
mhester
Participant
Posts: 622
Joined: Tue Mar 04, 2003 5:26 am
Location: Phoenix, AZ
Contact:

Post by mhester »

Fine - use the filter, but don't do the stage variables.
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

Pre-process to pick the date part from header in file and pass the date as a job parameter.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
Post Reply