Page 1 of 1

change insert into update

Posted: Thu 03 Nov 2005 11:39
by Hans
Hi,

Is it possible to change an insert into an update using TMyTable? This could be usefull when you discover (OnBeforePost) that the record you want to insert already exists. I want to be able to perform an update than if the new record from the input form is already in the database but has updated information.

The only way I can think of now is to use a TMyQuery, Compare the record in the database with the new record and decide to update using this TMyQuery. I hope it can be accomplished easier.

Is there a possibility to compare two records in two differend datasets?

best regards,
Hans

Posted: Fri 04 Nov 2005 12:26
by Ikar
MyDAC does not provide such functionality. Moreover, between checking and inserting other user can add such record.

Posted: Mon 19 Dec 2005 15:29
by ckelly
use the "ON DUPLICATE KEY UPDATE" in your "INSERT" statement