Joining 2 Datasets using between 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
MarkStewart
Participant
Posts: 17
Joined: Mon Nov 28, 2005 12:44 pm
Contact:

Joining 2 Datasets using between logic??

Post by MarkStewart »

I've created the 1st data set where I've left the FIN_YEAR and FIN_MONTH columns blank. The EFFECTIVE_DATE has a date value on the same dataset.

I've created a 2nd data set with FIN_YEAR, FIN_MONTH, BILL_ST, BILL_END.

How do I join the two datasets? I need to get the FIN_YEAR and FIN_MONTH from the 2nd data set to poplulate those same columns on the 1st dataset where EFFECTIVE_DATE is between BILL_ST and BILL_END. Any suggestions? Basically how do you code a between clause between two data sets?

Thanks,
Mark Stewart
Business Intelligence
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi And welcome aboard :)
Moving to EE Forum.
Please post in the correct forum next time :)
(You posted this in the Sever jobs forum and your post concerns the Enterprise Edition forum)
Thanks in advance,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
madhukar
Participant
Posts: 86
Joined: Fri May 20, 2005 4:05 pm

Re: Joining 2 Datasets using between logic??

Post by madhukar »

[quote="MarkStewart"]I've created the 1st data set where I've left the FIN_YEAR and FIN_MONTH columns blank. The EFFECTIVE_DATE has a date value on the same dataset.

I've created a 2nd data set with FIN_YEAR, FIN_MONTH, BILL_ST, BILL_END.

How do I join the two datasets? I need to get the FIN_YEAR and FIN_MONTH from the 2nd data set to poplulate those same columns on the 1st dataset where EFFECTIVE_DATE is between BILL_ST and BILL_END. Any suggestions? Basically how do you code a between clause between two data sets?

Thanks,[/quote]

if u have any matching key between the dataset then u can use the lookup condition in look up stage to give the between logic.
balajisr
Charter Member
Charter Member
Posts: 785
Joined: Thu Jul 28, 2005 8:58 am

Post by balajisr »

Hi

You need to use filter stage to filter the data based on effective data and join the two datasets based on the common key.

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

Re: Joining 2 Datasets using between logic??

Post by ray.wurlod »

madhukar wrote:if u have any matching key between the dataset then u can use the lookup condition in look up stage to give the between logic.
Can you be more specific? I understand that the lookup condition property determines whether the lookup is performed at all; if this condition is satisfied then the key value is looked up. It's an "=" condition, "between" is not possible in a Lookup stage as far as I am aware.

You might have more luck with a Join stage. But - without having the means to check right now - I think even this has limits on what you can do with a WHERE condition.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
madhukar
Participant
Posts: 86
Joined: Fri May 20, 2005 4:05 pm

Re: Joining 2 Datasets using between logic??

Post by madhukar »

ray,

2 options available in lookup

1 lookup on key
2 other than lookup key match , what else condition it has to meet

for the above req, we can give the following expn in lookup condition.
EFFECTIVE_DATE >= BILL_ST and EFFECTIVE_DATE <= BILL_END
MarkStewart
Participant
Posts: 17
Joined: Mon Nov 28, 2005 12:44 pm
Contact:

Post by MarkStewart »

Thanks for the suggestions. Since there was no common key which is why I'd be doing a between clause I used a join with a dummey key. Then in the transformer stage wrote a contraint that contained the between condition. Worked like a charm.
Mark Stewart
Business Intelligence
ameyvaidya
Charter Member
Charter Member
Posts: 166
Joined: Wed Mar 16, 2005 6:52 am
Location: Mumbai, India

Post by ameyvaidya »

Hi Mark,

I'd recommend a filter stage instead of the transformer.. Unless the transformer already exists as a necessary part of your job design. The filter should give you better performance.
Amey Vaidya<i>
I am rarely happier than when spending an entire day programming my computer to perform automatically a task that it would otherwise take me a good ten seconds to do by hand.</i>
<i>- Douglas Adams</i>
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

Call me crazy but isn't it easier and a whole lost faster to take BILL_DATE and derive the fields FIN_YEAR and FIN_MONTH instead of looking them up? It should be a relatively easy formula.

If that is not viable then why not map every FIN_YEAR and FIN_MONTH combination to a calendar year and calendar month. You then turn BILL_DATE into BILL_YEAR and BILL_MONTH and join them to the financial year lookup via key fields to CALENDAR_YEAR and CALENDAR_MONTH fields and bring back the FIN values.

I would avoid between lookups unless you have low data volumes and you can afford to load and filter all the extra rows.
Post Reply