ADOQuery bypasses deletion trigger instead

I am using Delphi 5 with SQL Server 2000 here.

I created ADOQuery on top of the updated view using the INSTEAD OF DELETE trigger.

The updated view is mainly used to manage soft deletions. It filters out records marked as deleted, and also hides the control column.

Everything works fine when I send DELETE commands directly to the database. I delete the record in the view, and the base table is updated, doing a soft delete as expected.

When I try to use ADOQuery to delete a record, it bypasses the view and deletes the record directly in the base table, so the trigger instead of it never starts on the view.

I also use reference constraints, and deleting because of them is wrong, but I don't know if that matters. This does not happen when issuing delete commands to the view.

Do any of you know how to get around this annoying behavior?

+3
source share
1 answer

Note that it is deleted directly from the main table instead? This is probably due to the fact that it discovers that it is a view and works with the main table itself. To prevent this, declare your view WITH VIEW_METADATA; see ALTER VIEW for more information.

ADO . , , , , , .

+1

Source: https://habr.com/ru/post/1766286/


All Articles