如何防止使用触发器删除?

时间:2021-04-11 10:00:12

I wish to create a trigger that would PREVENT any deletion on a given table if the day is either sunday or sat AND the time is between 14:00 and 16:00

我希望创建一个触发器,如果日期是周日或周六,时间在14:00至16:00之间,那么可以防止在给定的表上删除任何内容

Currently time is not a big deal, just how can I make the trigger stop the deletion action?

目前时间不是什么大问题,我怎么能让触发器停止删除动作呢?

1 个解决方案

#1


6  

CREATE OR REPLACE TRIGGER trg_timedelete
   BEFORE DELETE
   ON test

    WHEN (TimeLogicEvaluatesToTrue)
 BEGIN
     raise_application_error (-20100, 'You can not delete at this time');
  END;

The raising of the error will implicitly rollback the transaction and stop the delete.

引发错误将隐式回滚事务并停止删除。

#1


6  

CREATE OR REPLACE TRIGGER trg_timedelete
   BEFORE DELETE
   ON test

    WHEN (TimeLogicEvaluatesToTrue)
 BEGIN
     raise_application_error (-20100, 'You can not delete at this time');
  END;

The raising of the error will implicitly rollback the transaction and stop the delete.

引发错误将隐式回滚事务并停止删除。