Creating a trigger that deletes a row when an attribute becomes negative [oracle sql]?

前端 未结 2 719
闹比i
闹比i 2021-01-25 14:02

I would like to create a trigger that will delete a row when one of its attributes becomes negative. So far I have this, but it doesn\'t appear to be valid sql:

         


        
2条回答
  •  生来不讨喜
    2021-01-25 14:30

    This is not going to work. You can't perform DML on a table which is being manipulated by a row-level trigger. You will get a "mutating table" error.

    To get the result you want, your best bet is to have a flag or indicator column to identify that the record is to be deleted. Then, have a separate job or process or whatever to actually perform the delete.

提交回复
热议问题