Mapping to update existing rows and insert incoming rows



Hi,
I have a requirement where I need to load oracle table from a flat file ( abt 3000 rows) daily.
The flat src is
acct_no,val_dt,amt

The target table column is acct_no,val_dt,amt,create_ts,end_ts (default 31-dec-9999)

Primary key is (val_dt,acct_no,create_ts)

While loading data into target create_ts will be sysdate.

All recs from source will move to target table as insert .
But if record exists in table with same val_dt then
also update existing rows in table with end_ts=sysdate where val_dt= val_dt from source file.
There is a one-one mapping from source to target otherwise.

Pl help how to implement this approach.

i.e 1.Insert new records from source
2.If record exists with same val_dt in table and end_ts= '31-dec-9999'
update the existing recs also in the table with end_ts= sysdate using val_dt

I 've create a mapping for the same.But the mapping is slow while loading into target.

Below is sessiong log o/p :
applied rows : 3000
affected rows
: 3000*3000=9000000

Return to forum:

CREATE_TS should not have timestamp

From what you have written in the post, I understand that you are just using SYSDATE to populate the value of CREATE_TS. You should not have timestamp in this so try to use trunc(SYSDATE) while loading.

Cheers
Sarma.