Page 1 of 1

DELETE RECORD WITH SPECIFIC VALUE

Posted: Thu 05 Oct 2006 21:06
by biasko
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!

Posted: Fri 06 Oct 2006 14:34
by Antaeus
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.