I am working on a program that is supposed to insert hundreds of rows to the database per run.
The problem is that once the inserted data is wrong, how can we recover from that run? Currently I only have a log file (I created the format), which records the raw data get inserted (no metadata nor primary keys). Is there a way we can create a log that database can understand it, and once we want to undo the insertion we feed the database with that log file.
Or, if there is alternative mechanism of undoing an operation from a program, kindly let me know, thanks.
The fact, that this is only hundreds of rows, makes it succeptible to the great-grandmother of all undo mechanisms:
importrunswith a row for each run you do. I assume it has an integer auto-increment PKDELETE FROM sometable WHERE importid=$whateverIf you also have replace/update imports, go one step further
superseededbysuperseededbyINSERT INTO originaltable SELECT * FROM superseededtable WHERE superseededby=$whateverYou can clean up
superseededtablefor known-good imports, to make sure, storage doesn’t grow unlimited.