日期:2014-05-17  浏览次数:20716 次

新手求教触发器问题。
现有如下表
create table Book                 --书库
(
       bno char(6) primary key,      --书号
       bname varchar(20) not null,   --书名
       bpress varchar(20),           --出版社
       bprice numeric(5,2) not null, --定价
       bamount numeric(3)            --库存量                
)

create table Marketed               --销售
(
       mno char(5) primary key,     --销售单序号
       bno char(6),                --书号
       mdate date not null,         --销售日期
       mprice numeric(5,2),         --销售价格
       foreign key (bno) references Book(bno)
)

我想创建触发器实现在插入一条销售记录(即售出一本书后),实现将book中的bamount(库存量)-1的操作
触发器语句如下:
create trigger mark_tri after insert on marketed
       begin 
       update book set bamount = bamount -1
              where book.bno = new.bno;  
       end;
创建成功,但插入时报错ora-04098触发器无效或未通过验证。求解原因及解决方法。
注:使用PL/SQL developer
     Oracle 11g
PL/SQL Oracle?11g 触发器

------解决方案--------------------