User-defined SQL for 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
arindami
Participant
Posts: 28
Joined: Sat Jan 29, 2005 3:14 pm

User-defined SQL for LookUp

Post by arindami »

Hi
Is there anyway to have a user-defined SQL in DataStage without wirting
the select inside a batch i.e. only by using some stage in a sever job.
For instance I want to do a look up based on on a complex SQL involving
joining 3/4 tables , outer join on one and having a decode clause . etc.

Thanks
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post by pnchowdary »

Hi,

You can achieve this using the appropriate stage (ODBC,ORACLE etc) depending upon on the database on which your tables reside. In these stages, you have a place where you can put in your User Defined SQL.
Thanks,
Naveen
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

I would take your select and create a temp table with it. Import the metadata. Change the metadata so the fields that need prompts for are keys. Build your ODBC or OCI lookup then switch it to user defined. This will save lots of time.

Do you know how to CREATE TABLE using a SELECT statement?
Mamu Kim
ririr
Participant
Posts: 84
Joined: Sun Apr 04, 2004 8:59 pm

Post by ririr »

SELECT A.COL1, B.COL1, A.COL2, B.COL2, C.COL1 from TAB1 A, TAB2 B, TAB3 C WHERE A.KEY = B.KEY(+) AND B.KEY=C.KEY or can use a sub-query in the user defined sql in DRS stage, if you are using DS7 and higher.

The A.COL1, B.COL1, A.COL2, B.COL2, C.COL1 will be the columns in the DRS/Oracle/ODBC stage...


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

Post by ray.wurlod »

You can perform ANY legal SQL from a suitable passive stage type. The only extra thing you have to do is to make sure that your Columns grid contains the correct number of key and non-key columns so as to match what's specified (or implied) in the SQL. For example, parameter markers in WHERE clauses are matched by Key columns.
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