XML Input and Primary Keys

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
sbukhari1
Participant
Posts: 1
Joined: Thu Feb 18, 2010 1:51 pm

XML Input and Primary Keys

Post by sbukhari1 »

I am using a complex XML structure that has many levels. Within one level (3 levels deep) I am selecting a number of attributes to create an output file that is flat for that segment of the XML.

My job design is simple:

External Data Source -> XML Input -> Sequential File

In the output I am expecting 4 records. When I select the natural key of the segment as Key I get the unique values for the Key attribute, however all other attributes are repeated for the first occurrence of the natural key. When I select another attribute that I expect to be unique across 4 records I get unique value of that attribute but repeating Natural Key for the following 3 records.

What am I doing wrong?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Probably nothing. :wink:

FYI - that 'key' field option marks the Repetition Element and is nothing like a Primary Key. Typically one would set it to the lowest level element but sometimes to have to play games. If you truly have many 'levels' then you may need to pull the levels out with one XML Input stage and then use another to parse the levels themselves. I'm a little lost on your explanation so for someone like me, examples would be a Good Idea - snippets of your source and examples of what your output looks like in the various scenarios you outlined here.

Of course, Ernie probably grokked all this straight away, we could always wait for him. I'll sure he'll be along in a minute or two.... [whistles a merry ditty]

Oh, study material - be sure to pull down and cozy up with the XML Best Practices document on Kim Duke's website, all kinds of good information there on working XML with DataStage. 8)
-craig

"You can never have too many knives" -- Logan Nine Fingers
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Craig...you are too funny.

Indeed, Craig is right, the "key" is nothing more than an indicator for the repeating level that you want to retrieve. There are no keys --- just instances of elements.

Each "independent" repeating node (or deeply nested set of nodes) must be on its own link.

See lots of references as noted above -- I also have some things at my blog noted below.

Ernie
Ernie Ostic

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