Click to See Complete Forum and Search --> : DB2 replace


jrthor2
06-20-2008, 08:12 AM
I am writing a perl script to remove all rows from a table, and then load new rows from a csv file. I am using this command:

db2 connect to $DBNAME user $USER using $PASSWORD; db2 import from $JOBFILE of del replace into inet.insat_store_attr; db2 connect reset

If I have rows in the table already, and run this command, and the command rejects all the new rows, now my table is empty. Is there a way to do this without losing the rows until it successfully loads all the data?

Thanks.

NogDog
06-20-2008, 02:28 PM
You could create a temp table replicating the original, do your replacement, then if it fails copy the temp back to the original.

chazzy
06-20-2008, 02:43 PM
Is there some kind of signification as to when they were added? perhaps do the insert first, and then run a delete on older records.