change insert into update

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Hans
Posts: 52
Joined: Wed 24 Aug 2005 20:05

change insert into update

Post by Hans » Thu 03 Nov 2005 11:39

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

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Fri 04 Nov 2005 12:26

MyDAC does not provide such functionality. Moreover, between checking and inserting other user can add such record.

ckelly
Posts: 2
Joined: Fri 19 Nov 2004 16:47
Location: Tenerife, Spain

Post by ckelly » Mon 19 Dec 2005 15:29

use the "ON DUPLICATE KEY UPDATE" in your "INSERT" statement

Post Reply