How to run multi table insertion in a single transaction?

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
svhari76
Participant
Posts: 48
Joined: Tue Nov 16, 2010 5:04 pm

How to run multi table insertion in a single transaction?

Post by svhari76 »

Hi

how can we insert data into 2 different tables from transformer in a single transaction?

Scenario : Think of Master table and child table. From seq file i am getting data to both Master and child in a single row, i am separating the data and would liek to insert master data first and up on success insert the child records(multiple records) in a single transcation?

Any help would be greatly appreciated.
Hari
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Take the master and child links into a single ODBC stage. Within that ODBC stage set up a "grouped transaction".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
madhuker
Participant
Posts: 15
Joined: Wed Jul 19, 2006 1:05 am
Location: Hyderabad

Post by madhuker »

Hi Zenith,

As per your suggestion, tried to insert data into Master & Detail table using
Oracle OCI stage by checking Enable Transaction Grouping property in Transaction Handling tab.
However i am facing issues while loading data into master table.

For Example
Source Data :
col1 Col2 Col2
1 aa bb
2 bb cc

Master Table : Table1
Detail Table : Table2

In Transformer, condition used for Master Table link is

trim(Source col1)<>trim(lkp col1)

condition for Detail link is

trim(Source col1)=trim(lkp_col1)

Before first run there is no data in both Master & Detail table.
However, For First time run Data is not populated in the Master table even though Link contrain is satisfied.

Can you please suggest to how to handle this issue


Thanks a lot in Advance.
Thanks & Regards
Madhuker
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Different issue now. And you haven't explained the source or nature of this "lookup column" in your constraint. How is it derived?
-craig

"You can never have too many knives" -- Logan Nine Fingers
madhuker
Participant
Posts: 15
Joined: Wed Jul 19, 2006 1:05 am
Location: Hyderabad

Post by madhuker »

Hi,

Source is Flat File and Look up is based on Master Table(Key column col1).
Before 1st run, lookup contains no records. Therefore in 1st run all source records has to be loaded in the Master Table (by satisfying Master Table link condition). Again in 2nd run, if the source records exists in the master table then it has to load in the Detail table, also if there are any new records in the 2nd run source file then those records has to be loaded in the master table.

Thanks in Advance.
Thanks & Regards
Madhuker
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You need to check the success or failure of the lookup, not any kind of equality test. A lookup failure returns NULL values which will cause your contraints to always fail. Test for that instead.
-craig

"You can never have too many knives" -- Logan Nine Fingers
madhuker
Participant
Posts: 15
Joined: Wed Jul 19, 2006 1:05 am
Location: Hyderabad

Post by madhuker »

Hi Chulett,

Thanks a lot. Issue is resolved :D .
Thanks & Regards
Madhuker
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Post by Sreenivasulu »

Thanks a lot Ray.. I never thought that we can do transaction handling in such a way using datastage. Thanks again
major
Premium Member
Premium Member
Posts: 167
Joined: Mon Nov 26, 2007 12:21 am

Post by major »

Thanks for the information.

Never know that we can do that in DataStage...
Post Reply