Target Table Name in Source Column

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
jerome_rajan
Premium Member
Premium Member
Posts: 376
Joined: Sat Jan 07, 2012 12:25 pm
Location: Piscataway

Target Table Name in Source Column

Post by jerome_rajan »

We are faced with a slightly tricky situation here. We have source data coming in a single table. This table say 'SOURCE' has a column called 'TGT_TBL_NM' that defines the name of the target table that the corresponding row is inserted into. A sample of our source looks like

Code: Select all

col1  col2 col3 TGT_TBL_NM
1       2     3      Tab A
2       3     4      Tab A
4       5     6      Tab B
The first 2 rows would have to be inserted into Tab A and the last row into Tab B. We've got roughly 25-30 such targets.

I remember a similar question being asked at an interview but never paid much heed. Any pointers to solving the problem?
Jerome
Data Integration Consultant at AWS
Connect With Me On LinkedIn

Life is really simple, but we insist on making it complicated.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

For a small finite number of known table names multiple output links from a Filter or Transformer stage would serve as a solution - one link going to each of the known table names.

A dynamic solution would be more difficult. Perhaps use a server container (or server job) with a Folder stage to create separate files per table, then a sequence to read the table name from each file and set a job parameter containing the table name in the job that populates the table from the file.

You might be able to use the XML stage rather than a Folder stage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
jerome_rajan
Premium Member
Premium Member
Posts: 376
Joined: Sat Jan 07, 2012 12:25 pm
Location: Piscataway

Post by jerome_rajan »

Thanks Ray.

We're looking for a dynamic solution. I lost you at
...a sequence to read the table name from each file and set a job parameter containing the table name...
Can you please elaborate?
I'd be very interested to know how the XML Stage can help since that would mean a purely parallel job.
Jerome
Data Integration Consultant at AWS
Connect With Me On LinkedIn

Life is really simple, but we insist on making it complicated.
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Re: Target Table Name in Source Column

Post by SURA »

I am not sure about the solution what i am trying to give.

You need a Master Sequence for LOOPING (Get the list of tables names and loop it)

Then you need two DS Job. 1st one can be a Multiple instance job like below

Code: Select all

src  lkup with src (only tbl name) and write into a dataset

in here lkup where clause & dataset file name will get the tbl name as an input param
Final job can be a RCP load job.
Thanks
Ram
----------------------------------
Revealing your ignorance is fine, because you get a chance to learn.
Post Reply