Page 1 of 1

Truncate only record exists

Posted: Sun Jul 04, 2010 3:41 pm
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,

Posted: Sun Jul 04, 2010 5:05 pm
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?

Posted: Sun Jul 04, 2010 9:04 pm
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.