if i have more than 10 keys columns to vertical pivot logic

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
monaz
Participant
Posts: 98
Joined: Sat Aug 23, 2008 3:14 am

if i have more than 10 keys columns to vertical pivot logic

Post by monaz »

hi All,

I have a requirement in which i have 10 keys columns and i need to perform vertical pivot conversion for the data.

Please suggest..

Here is the example

INPUT:-

AKey BKey CKey DKey EKEY FKEY GKEY HKEY IKEY JKEY SeqNoKEY ADD
1 2 11 a b c d e f g 1 A
1 2 11 a b c d e f g 1 P
1 2 11 a b c d e f g 1 P
1 2 11 a b c d e f g 1 L
1 2 11 a b c d e f g 1 E
OUTPUT:-
AKey BKey CKey DKey EKEY FKEY GKEY HKEY IKEY JKEY ADD
1 2 11 a b c d e f g APPLE

I tried using the using stage variables in transformer stage and passing to Remove duplicate stage and using the below logic
StgVarCurrent;- (AKey: BKey: CKey: DKey: EKEY; FKEY: GKEY: HKEY: IKEY: JKEY)

stgvarpervious:- StgVarcurrent

StgVarADD:- ADD

StgVarlogic- If StgvarCurrent<> StgVarPerious then StgVarlogic else StgVarADD:StgValogic

Please correct me if my logic is wrong and i am not getting the required output

Please note i have not used Seq_no anywhere in my logic

Thanks
sbass1
Premium Member
Premium Member
Posts: 211
Joined: Wed Jan 28, 2009 9:00 pm
Location: Sydney, Australia

Post by sbass1 »

Some people are the Michael Jordan's of Datastage. I'm more like Muggsy Bogues :-)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What output ARE you getting?

There's no limit on the number of pivot keys - you just have to handle them all.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

And their number doesn't change the "how" of that processing.
-craig

"You can never have too many knives" -- Logan Nine Fingers
throbinson
Charter Member
Charter Member
Posts: 299
Joined: Wed Nov 13, 2002 5:38 pm
Location: USA

Post by throbinson »

The order of the Stage variables is of paramount importance. The number of keys is not. If the order is as you've listed them above then the "IF" stage variable will never detect a key change. The "current" comes first followed by the stage variable that detects the key change and then the assign "current" to "previous" stage variable. It should be intuitive that your input data must be sorted in key(s) order as well.
monaz
Participant
Posts: 98
Joined: Sat Aug 23, 2008 3:14 am

Post by monaz »

throbinson wrote:The order of the Stage variables is of paramount importance. The number of keys is not. If the order is as you've listed them above then the "IF" stage variable will never detect a key change. The "current" comes first followed by the stage variable that detects the key change and then the assign "current" to "previous" stage variable. It should be intuitive that your input data must be sorted in key(s) order as well.
Thanks to all,

Now the problem is that after sorting the data in the sorter stage i am not getting correct format data.

since i have 10key columns can i sort in any order. i mean key3 can i keep at keycolumn10 th position is it possible?

Please advice
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Ordinal position of the key columns in the key is independent of the order that you specify that they be sorted.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
throbinson
Charter Member
Charter Member
Posts: 299
Joined: Wed Nov 13, 2002 5:38 pm
Location: USA

Post by throbinson »

Yeah, what he said.
Now, you know you'll have to handle the outliers as special cases.
For example;
1. The very first row in won't match prev but may not have to be written out immediately.
2. The very last row in needs to be triggered to write it out, even if curr matches prev.
Post Reply