Trouble with TMyQuery.SQLDelete

Trouble with TMyQuery.SQLDelete

Postby 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.
jarot
 
Posts: 5
Joined: Wed 04 Jan 2006 04:07

Postby 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.
swierzbicki
 
Posts: 451
Joined: Wed 19 Jan 2005 09:59

Postby 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.
Ikar
 
Posts: 1693
Joined: Thu 28 Oct 2004 13:56


Return to MySQL Data Access Components