DELETE RECORD WITH SPECIFIC VALUE

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
biasko
Posts: 6
Joined: Thu 05 Oct 2006 20:55

DELETE RECORD WITH SPECIFIC VALUE

Post by biasko » Thu 05 Oct 2006 21:06

Hi!

In MyQuery generates me an DELETESQL: DELETE FROM table WHERE id=:OLD_ID

works fine if I want to delete selected record like MYQUERY.DELETE;.

Now I want to delete like this
DELETE FROM table WHERE id_secondtable=:idfromsecondtable

Yes I can put new QUERY on my form and write this SQL in it and do MYnewQUERY.CLOSE;
MYnewQUERYOPEN;
but I don't want to create new query, I want to use my old QUERY and use QUERY.DELETE option.

how to do this?
Is there any tutorials or demo programs how to do different things with MYQUERY ?

Thanks!

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Fri 06 Oct 2006 14:34

DeleteSQL is intended for execution when deleting current record of the record set. You can use ExecSQL method of TMyConnection component to execute DElETE statement. For example:
MyQuery.Connection.ExecSQL('DELETE FROM table WHERE id=1234', []);
The second way is usage of TMyCommand component.

> Is there any tutorials or demo programs how to do different things with MYQUERY ?
You can find MyDAC demos in %MyDAC%\Demos\ directory.
%MyDac% is the MyDAC installation path on your computer.

Post Reply