Looping in Datastage

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
srinagesh
Participant
Posts: 125
Joined: Mon Jul 25, 2005 7:03 am

Looping in Datastage

Post by srinagesh »

Hi,

My Datamodel is as follows

fact: SourceLocationID, DestLocationId,MonthID
TimeDim : MonthID

I need to do the following

1. select sourcelocationId, destLocationId,min(month) from fact group by sourceLocationId,DestLocationID ==> Call it A

2. Select A.SourceLocationId,A.DestLocationId, B.Month
from A, Month B
where A.MonthId <= B.MonthID ==> Call it C

3. Truncate Target Table; Insert into Target Table as select * from C


Could you please suggest a datastage solution for this.


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

Post by ray.wurlod »

DataStage implicitly has the looping construct.
Do your select from A, perform a range lookup against B, and use a constraint expression to determine whether row was returned from B (and therefore whether to send on to target). Table C is not required. If you need a multi-row return from B, you will need to use an ODBC stage for the lookup, since the OCI stage only ever returns one row.
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