Duplicate segment loading & creating relationship (XML)

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
Kumar1234
Participant
Posts: 14
Joined: Mon Feb 04, 2008 5:59 am

Duplicate segment loading & creating relationship (XML)

Post by Kumar1234 »

Code: Select all

<XYZDetails> ...root
	<ABC_Segment>  ....parent segment
	     	<AAA>11111</AAA>
		<BBB>222</BBB>
		<CCC>3333</CCC>
	     <GPP_Segment> ....child segment
		<DDD>123<DDD>
		<EEE>1122<EEE>
	     </GPP_Segment>
	</ABC_Segment>
	<ABC_Segment>
	     	<AAA>11111</AAA>
		<BBB>222</BBB>
		<CCC>3333</CCC>
	     <GPP_Segment>
		<DDD>777<DDD>
		<EEE>0<EEE>
	     </GPP_Segment>
	</ABC_Segment>
	<ABC_Segment>
		<AAA>9999</AAA>
		<BBB>0</BBB>
		<CCC>PPPP</CCC>
	</ABC_Segment>
<XYZDetails>
I have to load the above XML into a table. ABC_Segment is a repetition segment. I need to create a key based on AAA,BBB,CCC attribute values. I am concatenating values of all 3 attributes and making as key (eg: 11111|222|3333) and I am able to create keys 1, 2, 3 respectively.
You can see first 2 segment (ABC_Segment) repetitions are duplicate and I have to load the duplicates as as with keys.
So I loaded as:

Code: Select all

Lkp_Key			     Key_Value
11111|222|3333		  1
11111|222|3333		  2
9999|0|PPPP		     3
Problem is, now I have to lookup on this to get the key_value for the child segment (GPP_Segment).
So can anyone help me to how can I create a unique lookup key so as that I can tag the correct child to its respective parent.

I tried with concatenating a @INROWNUM at the end of key but I dont know how the child segment will be able to identify its correct parent.

Hope I am able to explain my question.

Ps : I am doing this on server job.
Thanks...Kumar
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What have you tried? That is, how have you programmed the properties of the XML stage, including xpaths?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Kumar1234
Participant
Posts: 14
Joined: Mon Feb 04, 2008 5:59 am

Post by Kumar1234 »

I tried to use position() instead of text() on xpath and it did provide sequence number for position of ABC_Segment. But this is not working incase of lookup parent (ABC_Segment) for child GPP_Segment because position() can be used in the segment where the repetition element exist.

can we program the description area ? that is Xpath area ?
What kind of program can we do ? and where ?

Pleaes help.
Thanks...Kumar
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

...since the ABC Segment doesn't have any identifying characteristics (a typical xml design where uniqueness is important might have a sub-node that is a sort of header, directly underneath ABC, or else an attribute, like abc_ID="01" directly inside the ABC_Segment element), one suggestion is to parse this xml in chunks.....

...first, pull the ABC Segment with a single large varchar column, whose xpath (description property) just ends with /ABCSegment/ , making it the repeating element (you'll get one row for every ABC Segment) ...then create your unique counters....and then pass it into another xmlInput Stage.....in that one, pull your columns defined as elements directly under ABC, with the repeating element assigned to a column in the <GPP Segment>

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
Post Reply