我想写一个当插入的 时间跟系统时间差3天以上就提示不能插入的触发器,谁来帮我写成啊
create or replace trigger chtime
after insert or update on student
REFERENCING old as old NEW AS new
for each row
declare
-- rxtime date;
begin
if inserting then
insert into student(sno,:sna,age,sex,cno,deptno,qinshi,rxtime) Values (:new.sno,:new.sna,:new.age,:new.sex,:new.cno,:new.deptno,:new.qinshi,:new.rxtime);
end if;
if(
select(to_char(sysdate,'ddd')-to_char(:new.rxtime,'ddd'))from student )>3
then
--raise_application_error(-20001,'插入的时间不对');
DBMS_OUTPUT.PUT_LINE(‘更新rxtime失败');
delete from student where sno=:new.sno;
end if;
end chtime;
/
create or replace trigger chtime
after insert or update on student
REFERENCING old as old NEW AS new
for each row
declare
-- rxtime date;
begin
if inserting then
insert into student(sno,:sna,age,sex,cno,deptno,qinshi,rxtime) Values (:new.sno,:new.sna,:new.age,:new.sex,:new.cno,:new.deptno,:new.qinshi,:new.rxtime);
end if;
if(
select(to_char(sysdate,'ddd')-to_char(:new.rxtime,'ddd'))from student )>3
then
--raise_application_error(-20001,'插入的时间不对');
DBMS_OUTPUT.PUT_LINE(‘更新rxtime失败');
delete from student where sno=:new.sno;
end if;
end chtime;
/
after insert on student for each rowbegin if to_char(sysdate, 'ddd') - to_char(:new.rxtime, 'ddd') > 3 then
DBMS_OUTPUT.PUT_LINE('更新rxtime失败');
else
insert into student
(sno, sna, age, sex, cno, deptno, qinshi, rxtime)
Values
(:new.sno,
:new.sna,
:new.age,
:new.sex,
:new.cno,
:new.deptno,
:new.qinshi,
:new.rxtime);
end if;
end if;
end chtime;
/
before insert on student for each rowbegin if to_char(sysdate, 'ddd') - to_char(:new.rxtime, 'ddd') > 3 then raise_application_error(-2001,'插入时间不对');end if;
end chtime;
create or replace trigger chtime
before insert on student for each row
when (floor(sysdate-new.rxtime)>3))begin raise_application_error(-2001,'插入时间不对');end if;
end chtime;