Trouble with TMyQuery.SQLDelete

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Posts: 5
Joined: Wed 04 Jan 2006 04:07

Trouble with TMyQuery.SQLDelete

Post by jarot » Wed 25 Jan 2006 03:14

With BDE, i can modify the generated query at SQLInsert, SQLUpdate or SQLDelete. Especially when I wanted to do some cascading delete or update.

Something like this:

-- I added this
DELETE table_detail
WHERE field1 = :old_key1

-- automatically generated
DELETE table_master
WHERE field1 = :old_key1

However, it does not work with MyDac. Error. And I can't use semicolon to separate each command either.

Need help, please.

Posts: 451
Joined: Wed 19 Jan 2005 09:59

Post by swierzbicki » Wed 25 Jan 2006 10:00

You can MySQL let the job for you !
Be sure to works with InnoDB table and set the appropriates foreigns keys.

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

Post by Ikar » Thu 26 Jan 2006 13:18

Delphi and MyDAC don't allow such complex statements in SQLDelete. It's implied that only one record in the simple dataset is processed. To solve your problem try to use stored procedure or trigger (if your MySQL server supports them), or try to handle BeforeDelete event of your dataset, or any other manual way.

Post Reply