创建发出警告/错误的触发器

时间:2016-11-12 14:54:19

标签: mysql triggers

需要使用phpmyadmin创建触发器的帮助,它会在插入数据之前发出警告。情况很像这样:

CREATE OR REPLACE TRIGGER secure_item
   BEFORE INSERT
   ON item
BEGIN
   IF (TRIM(TO_CHAR (SYSDATE, 'DAY')) IN ('SATURDAY', 'SUNDAY'))
      OR (     TO_NUMBER(TO_CHAR(SYSDATE, 'HH24')) NOT BETWEEN 8 AND 15 )
   THEN
      raise_application_error (-20500,

                               'You may insert into test table only during business hours.'
      );
   END IF;
END;
/

1 个答案:

答案 0 :(得分:0)

将sysdate替换为

NOT hour(now()) between 8 and 15 OR weekday(now()) > 4