Copying Header Record Count to Detail

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
chakkara
Participant
Posts: 5
Joined: Thu Jun 28, 2018 7:05 pm

Copying Header Record Count to Detail

Post by chakkara »

Hi All,

I have a requirement to copy header count and paste it in its detail records.I need logic to create col4 based on header.

I tried splitting header and detail records and did left outer join with detail record link as primary. I did find duplicates and it got cross joined.

Note : My file contains multiple headers and detail record count will present at individual headers

Sample Input :

Col1 Col2 Col3
H 2 A
D 1 A
D 2 A

H 3 A
D 1 A
D 2 A
D 3 A

H 4 A
D 1 A
D 2 A
D 3 A
D 4 A


Expected Output :

Col1 Col2 Col3 Col4
H 2 A
D 1 A 2
D 2 A 2

H 3 A
D 1 A 3
D 2 A 3
D 3 A 3

H 4 A
D 1 A 4
D 2 A 4
D 3 A 4
D 4 A 4

Thanks in advance.
chakkara
Participant
Posts: 5
Joined: Thu Jun 28, 2018 7:05 pm

Re: Copying Header Record Count to Detail

Post by chakkara »

Please help me and provide permanent solution to handle this requirement.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:!: Patience, Grasshopper. People help when and if they can and they will provide guidance - it's up to you for the "permanent solution" part.

A bit old but since I've done much the same thing and written it up before, managed to find this post which has some thoughts on approaching this. Hope it helps.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

So this is marked as resolved.

I presume you learned about how to use stage variables to "remember" things.

Do let us know.

Oh, and by the way, not everyone spends the whole weekend logged in to DSXchange!
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply