我试图在插入之前创建触发器但是会出现一些错误

时间:2013-01-02 15:55:38

标签: oracle oracle10g oracle11g

CREATE OR REPLACE TRIGGER btinsert
BEFORE INSERT ON sample
  BEGIN
    IF (TO_CHAR(SYSDATE,'HH24:MI')
          NOT BETWEEN ('08:00' AND '22:00') THEN 
    RAISE_APPLICATION_ERROR(-20500, 'you may insert'
       ||' into EMPLOYEES table only during '
       ||' normal business hours.'); 
   END IF;
END;

但是我收到了一个错误:

  

第8行的错误:PLS-00103:遇到符号“END”
  6. RAISE_APPLICATION_ERROR(-20500,'你可以插入'
  7. ||'只在'
期间进入EMPLOYEES表   8. ||'正常营业时间。');
  9.结束IF;
  10.结束;

1 个答案:

答案 0 :(得分:1)

你有一些缺失的括号和多余的括号。

CREATE OR REPLACE TRIGGER btinsert
BEFORE INSERT ON sample
  BEGIN
    IF (TO_CHAR(SYSDATE,'HH24:MI') NOT BETWEEN '08:00' AND '22:00') THEN 
    RAISE_APPLICATION_ERROR(-20500, 'you may insert'
       ||' into EMPLOYEES table only during '
       ||' normal business hours.'); 
   END IF;
END;
/