Truncate only record exists

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
senthil_tcs
Premium Member
Premium Member
Posts: 40
Joined: Tue Oct 14, 2008 3:30 pm
Location: London

Truncate only record exists

Post by senthil_tcs »

Hi,

I want to truncate the target table only when the record comes from source system. My source table is in oracle database and target database is in DB2. The requirement is to move the record from source to target if record exists in the source tables, if no record exists in the source then we need to the use existing data in the tables.

Any suggestion how to implement this logic without using routine.

Thanks,
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Somewhat lost regarding what it is you need to do. :?

Are you saying that if there are records in the Oracle table, that you need to truncate the DB2 table and then write all of the Oracle records into the DB2 table? But if the source Oracle table is empty, then you need to do nothing on the DB2 side... i.e. leave the target table alone and intact?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Use a sequence with two Job activities. The first job determines whether there are any rows in the table and parks that result, say in its user status area. This activity has a custom trigger that fires only if that count is greater than zero. The second Job activity performs the truncate.
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