If you were using a database that supported it, you could use a BEFORE DELETE
trigger. However, according to a search on the Absolute Database documentation, there's no support for CREATE TRIGGER
and a search on triggers
at the same site returns nothing about them either.
The lack of trigger support probably just leaves you with performing an INSERT
into the other table first, before doing the DELETE
from your LOG
table. According to the documentation again, a query is able to be used as the source of data for an INSERT
(see the second example on the linked page). This means you can do something like this:
ABSQuery1.SQL.Text := 'insert into LOG_ARCHIVE'#13 +
'(select * from LOG where status = ''Yes'')';
ABSQuery1.SQL.ExecSQL;
ABSQuery1.Close;
{
No need to use SQL.Clear here. Setting the SQL.Text replaces
what was there before with new text.
}
ABSQuery1.SQL.Text :='delete from LOG where status=''YES''';
ABSQuery1.ExecSQL;
You really should wrap this entire operation in a transaction (Delphi example here), so that in case something fails both the INSERT
and DELETE
can be undone. (For instance, if the INSERT
works putting the rows in the LOG_ARCHIVE
file, but the DELETE
then fails for some reason, you have no way to remove the rows you inserted into the archive file.) A transaction can be started before you do the INSERT
, rolled back if it (or the DELETE
fails or committed if both of them succeed.