如果用户尝试将当前日期替换为将来的日期,我想启动触发器。但是触发器中可能不允许使用子查询。我该如何解决这个问题?任何建议......
CREATE OR REPLACE TRIGGER check_join_date
BEFORE UPDATE OF join_date ON DOCTOR
FOR EACH ROW
WHEN (NEW.join_date > (SELECT CURRENT_DATE+1 FROM DUAL) )
BEGIN
RAISE_APPLICATION_ERROR(-20509,'Do not Enter Future Date..');
END check_join_date;
/
在Oracle中运行此代码后,我收到此错误。
ORA-02251: subquery not allowed here
答案 0 :(得分:3)
测试这个
CREATE OR REPLACE TRIGGER check_join_date
BEFORE UPDATE OF join_date ON DOCTOR
FOR EACH ROW
WHEN (NEW.join_date > CURRENT_DATE+1)
BEGIN
RAISE_APPLICATION_ERROR(-20509,'Do not Enter Future Date..');
END check_join_date;
/