Using lookups without specifying lookup 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
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Using lookups without specifying lookup keys

Post by Marley777 »

I am trying to pull a field off of a DB2 table, that contains just one value. It contains nothing but a counter that I need to pull off for each record I process. The problem I am running into is that this table does not contain a key to lookup on. I simply need to select the field off of the table and then carry that field on in my processing. There are no lookup keys to use. And when I use the lookup stage, it asks what my lookup key is...and I do not have one. Can I use a lookup stage to access a DB2 without keys? Or is there another stage I can use?

Thanks for your help!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You need a key. If nothing qualifies, make one up! For your situation where you have a single row, hard-code the key to something like a "1" and then use that (again, hard-coded) in your job. Works great! :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
waitnsee
Participant
Posts: 23
Joined: Tue Jul 06, 2004 10:20 am

You can use the sparse mode lookup

Post by waitnsee »

You can use the sparse mode in the looku stage to overcome this problem
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sorry, I seem to have lost track of what Forum I was in and gave you a Server answer. My apologies if it isn't applicable.
-craig

"You can never have too many knives" -- Logan Nine Fingers
richdhan
Premium Member
Premium Member
Posts: 364
Joined: Thu Feb 12, 2004 12:24 am

Post by richdhan »

Hi RStone,

As Craig mentioned you need to make up one. Just before the lookup stage add a column generator stage and add a column with value 1. When you are select from DB2 select the counter as well as an alias column with value equal to 1. Now you can use this common column name from the main stream and lookup stream as the key column and retrieve the counter value.

HTH
--Rich

Pride comes before a fall
Humility comes before honour
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You could even constraint on the row number being equal to 1. Do this on the Selection tab.
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