我想写一个当插入的 时间跟系统时间差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;
/
解决方案 »
- ORACLE DBLINK 奇怪
- 如何查询一个字段是否以数字开头
- 动态创建表与索引
- 定期运行SQL
- 一个超难的查询语句,很有挑战性,100分求答案
- 我们通常都配置oracle client目录里面的tnsnames.ora,但是在oracle的network\admin里面也有同名文件,这是做什么用呢?
- DELPHI6+ADO+ORACLE,遇到一个问题,取不出来负的整数
- 请问有装Oracle 10G For win版本的仁兄么???教教我用法!
- “tns操作超时”的错误原因都有哪些
- oracle出错啦,我该怎么办呀,急急急!!!!!!
- group by的以后如何连接其他字段
- 存储过程中的时间查询问题
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;