SQL> create trigger test_tri
2 before insert or update or delete on scott.test1 fo
3 begin
4 if inserting then
5 insert into scott.test2 values(0);
6 elsif updating then
7 insert into scott.test2 values(1);
8 elsif deleting then
9 insert into scott.test2 values(3);
10 end if;
11 end;
12 /触发器已创建SQL> insert into scott.test1 values(87);
insert into scott.test1 values(87)
*
第 1 行出现错误:
ORA-04098: 触发器 'SYS.TEST_TRG' 无效且未通过重新验证
为什么啊
create or replace trigger aa
before insert or update or delete on emp
for each row
begin
if inserting then
insert into emp(empno) values(0);
elsif updating then
insert into emp(empno) values(1);
elsif deleting then
insert into emp(empno) values(3);
end if;
end aa;
在触发器里可以看到
打上小红叉说明就是写的不对
呵呵
INCREMENT BY 1 -- 每次加几个
START WITH 1 -- 从1开始计数
NOMAXVALUE -- 不设置最大值
NOCYCLE -- 一直累加,不循环
NOCACHE -- 不建缓冲区--建立触发器,名称为BBSTopic_trigger
CREATE TRIGGER "BBSTopic_trigger" BEFORE
INSERT ON BBSTopic FOR EACH ROW WHEN (new.TID is null)
begin
select TID_sequence.nextval into: new.TID from dual;
end;
create table BBSTopic(
TID number(4) NOT null primary key,--标识主键列
TNumber integer not null,--帖子编号
TSID integer NOT NULL references BBSSection(SIDID),--所在版块 外键--BBSSection(SIDID)
TUID VARCHAR(20) NOT NULL references BBSUser(UIDID),--发帖人 外键--BBSUser(UIDID)
TReplyCount integer not NULL,--回复数
TEmotion blob null,--回复表情
TTopic varchar(20) not NULL UNIQUE,--唯一约束 发帖主题
TContents varchar(200) not null,--正文
TTime date DEFAULT sysdate not null,--回复时间 系统自动产生
TClickCount integer NOT NULL,--点击数
TFlag char(1) DEFAULT 'F' check (TFlag in('S','F')),--发帖状态 成功/不成功
TLastClickT date DEFAULT sysdate not null--最后回复时间
);
insert into BBSTopic(TNUMBER, TSID, TUID, TREPLYCOUNT, TTOPIC, TCONTENTS, TCLICKCOUNT, TFLAG) VALUES
(1,1,'B00001',10,'天下新闻','时事新闻,了解身边发生的事',20,'S');
数据插不进去,有个小红叉,求解决