TMyQuery->Delete(); Question

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Minotaurus007
Posts: 14
Joined: Wed 27 Aug 2008 16:03

TMyQuery->Delete(); Question

Post by Minotaurus007 » Thu 29 Jan 2009 18:47

Code: Select all

Query->SQL->Text = "SELECT * FROM T1, T2 WHERE [condition]";
Query->Open();
Now, using DBNavigator I can easily delete a record from this query via nbDelete. The selected records are also deleted from T1 and T2. How can I invoke this delete-operation without using a DBNavigator? The following code just deletes the record from T2 only, and not from T1:

Code: Select all

Query->SQL->Text = "SELECT * FROM T1, T2 WHERE [condition]";
Query->Open();
Query->Delete();
What's going wrong?

-mino

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

Post by swierzbicki » Fri 30 Jan 2009 09:55

Nothing wrong here. The component cannot decide by itself to delete both records.

There is two solutions :
- 1st one :
You can use foreign keys so that when the "master" data is deleted, all "details" data will be deleted to.

- 2nd one :
Link a MyUpdate component to the corresponding MyQuery and write all necessary SQL statements to delete data from table1 and table 2

Post Reply