Cross join

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
snassimr
Premium Member
Premium Member
Posts: 281
Joined: Tue May 17, 2005 5:27 am

Cross join

Post by snassimr »

hi !!!

I need to perform the following task :

A B 2
A C 3
A B 4
A C 1

I need to get all combinations of two first fields with a third field :

A B 1
A B 2
A B 3
A B 4
A C 1
A C 2
A C 3
A C 4

If any easy way to get it in DS ?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The answer to the question is "yes".

Where are the first two fields coming from? Where is the third field coming from? How do you combine them? We can not give the best answer to your original question without this knowledge.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
snassimr
Premium Member
Premium Member
Posts: 281
Joined: Tue May 17, 2005 5:27 am

Post by snassimr »

first columns are in seq files . For third column I have another seq file.
I can to load both files to DB and do there a cross join . But I want to do it in DS.

I put an example that more clear :

Seq_file 1
A B
A C
Seq_file 2
1
2

I want to get :

A B 1
A B 2
A C 1
A C 2
peddidsx
Premium Member
Premium Member
Posts: 55
Joined: Wed Dec 26, 2007 8:20 am

Post by peddidsx »

Add another extra column to both the files as KEY and set it to default as '1'.Then Lookup file1 on file 2 based on 'KEY' by setting the option in LookUpStage as to allow duplicates(Allow multiple rows from the reference link).This should result the output as desired.
Rajesh Peddi
rameshrr3
Premium Member
Premium Member
Posts: 609
Joined: Mon May 10, 2004 3:32 am
Location: BRENTWOOD, TN

Post by rameshrr3 »

Then Lookup file1 on file 2 based on 'KEY' by setting the option in LookUpStage as to allow duplicates(Allow multiple rows from the reference link).
Note that this will work only if you create a hashed file of file2 data with UV Stage compatibility [SERVER JOBS]
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Another possibility is to use an ODBC stage, with the DSN using the driver for text files.
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