Page 1 of 1

Trouble with TMyQuery.SQLDelete

Posted: Wed 25 Jan 2006 03:14
by jarot
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.

Posted: Wed 25 Jan 2006 10:00
by swierzbicki
You can MySQL let the job for you !
Be sure to works with InnoDB table and set the appropriates foreigns keys.

Posted: Thu 26 Jan 2006 13:18
by Ikar
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.