Subject Better way to update table?
Author gorepj
I have an Import routine that updates a table. If a record already
exists then it is updated otherwise it is appended. I impelement this
by having a primary key constraint and program SQL statements in
Delphi accordingly.
//Try to append record
INSERT INTO MyTable (Myfield ...) VALUES (MyValue ...)
//Primary key violated therefore update that record instead
UPDATE MyTable SET MyField = MyValue WHERE KeyField = SearchKeyValue

This works beautifully but if I don't commit every statement I lose
cached updates / inserts when the exception occurs.

Is there a better way?
Peter Gore