How to retrieve multiple rows via lookup?

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
jasjad999
Participant
Posts: 3
Joined: Sun Oct 10, 2004 1:26 am

How to retrieve multiple rows via lookup?

Post by jasjad999 »

Need help to resolve a problem. We have a sequential file that contains the "partial" key for a table. We would like to do a lookup to the table and fetch every rows (0 to many) that matches this partial key. Is this possible? Here is any example,

Seq file contains, let say, Employee Last Name and DOB,
Smith, 01/01/80
Lee, 08/15/60
.
.

In the EMP table, the columns are
Last Name (part of the key)
DOB (part of the key)
First Name (part of the key)
.
.

And data in the EMP table would look like,
Smith John 01/01/80 ......
Smith James 02/02/82 .....
Smith Jenny 03/03/84 ....
Lee Betty 05/01/60 ....
Lee Brenda 04/04/62 ....


For 1st record in Seq file (Smith), we need to retrieve 3 records (John, James and Jenny). For 2nd record in Seq file (Lee), we need to get 2 records (Betty and Brenda). More of an "explicit cursor" situation.

Is this possible? If yes, any suggestions?

Thank you everyone,
Kevin
dhiraj
Participant
Posts: 68
Joined: Sat Dec 06, 2003 7:03 am

Post by dhiraj »

Kevin,

Go to the properties page of the transformer where you are doing the lookup --> inputs tab ---> select your look up link from the drop down list-->check the box which says link returns multiple rows.i am assuming you are using ODBC stage for look up

Search the forum. This has been discussed earlier extensively.

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

Post by ray.wurlod »

It is possible, as dhiraj says, but only when the reference input link is fed from the ODBC and UniVerse stage types.
Open Help from Manager or Designer and open the topic called Defining Multirow Lookup for Reference Inputs
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
jasjad999
Participant
Posts: 3
Joined: Sun Oct 10, 2004 1:26 am

Post by jasjad999 »

Hi dhiraj/Ray,

Thanks for your information.

Do you remember some of the "topics" related to this subject matter? I've searched the forum with many different key words (i.e. multiple rows, lookup, multirow, etc.), but wasn't able to find any topic closely related to this.

BTW, I am using ORAOCI8 stage to access the DB table.

Thanks,
Kevin
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

jasjad999 wrote:Do you remember some of the "topics" related to this subject matter?
:? Searching for 'multirow' in this forum worked fine for me, returning several posts including this one on the subject, which contains some specifics.
you also wrote:BTW, I am using ORAOCI8 stage to access the DB table.
As mentioned above - you can't. Only the ODBC stage for database tables and the UV stage for Universe/hashes support this feature.

How big is your Employee table? Load it into a hash file first and use a UV stage to access it and perform the actual lookup.
-craig

"You can never have too many knives" -- Logan Nine Fingers
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

Try this topic:
viewtopic.php?t=84998

viewtopic.php?t=85087

Both of them talk about storing multi rows in hash files and keeping the exact matching of the hash file key.
Post Reply