change insert into update

change insert into update

Postby Hans » Thu 03 Nov 2005 11:39


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,
Posts: 52
Joined: Wed 24 Aug 2005 20:05

Postby Ikar » Fri 04 Nov 2005 12:26

MyDAC does not provide such functionality. Moreover, between checking and inserting other user can add such record.
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Postby ckelly » Mon 19 Dec 2005 15:29

use the "ON DUPLICATE KEY UPDATE" in your "INSERT" statement
Posts: 2
Joined: Fri 19 Nov 2004 16:47
Location: Tenerife, Spain

Return to MySQL Data Access Components