Oracle触发日期 [英] Oracle trigger for date

查看:170
本文介绍了Oracle触发日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CREATE OR REPLACE TRIGGER CRIMEDATE
    BEFORE INSERT or UPDATE of DATE_CLOSED
    ON CRIME
    for each row
    declare :new.date_closed

BEGIN

   if (:new.date_closed < crime_date) then raise_application_error(-20002, 'Date Closed must be after crime date');
   end if;
END;

我正在尝试创建一个触发器,如果​​为date_closed输入的日期早于实际犯罪日期,则将触发该触发器,但是我不断收到以下错误消息:

I am trying to create a trigger that will fire if the date entered for date_closed is before the actual crime date but i keep gettng the following error:

    Error at line 1: PLS-00103: Encountered the symbol "" when expecting one of the 
    following: begin function pragma procedure subtype type <an identifier> <a double-quoted 
    -identifier> current cursor delete exists prior The symbol "" was ignored. 0.06 seconds

我已经尝试了很长时间了,请问有人可以帮忙吗?谢谢

I've been trying for ages to figure it out, can any one help? thanks

推荐答案

尝试一下:

CREATE OR REPLACE TRIGGER CRIMEDATE
    BEFORE INSERT or UPDATE of DATE_CLOSED
    ON CRIME
    FOR EACH ROW
BEGIN
   IF (:new.date_closed < :new.crime_date)  THEN
      raise_application_error(-20002, 'Date Closed must be after crime date');
   END IF;
END;

这篇关于Oracle触发日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆