【发布时间】:2014-01-21 11:50:23
【问题描述】:
我正在尝试创建一个触发器,该触发器将在订单表中输入项目时运行,产品表中的数量应该减少
create or replace trigger quantity_dicr after update of quantity on products for each row
declare
quantity float;
begin
select quantity into quantity from products where o_id = :new.o_id;
set quantity = quantity + :new.quantity ,
where o_id= :new.o_id;
end quantity_dicr;
表格
create table products(
prod_id numeric not null,
prod_name varchar2(50) not null,
quantity numeric not null,
price numeric not null,
constraint prod_id_pk primary key(prod_id)
)
create table orders
(
prod_id numeric not null,
o_id numeric not null,
quantity numeric not null,
o_sum numeric not null,
constraint fk_products foreign key (prod_id) references products(prod_id),
constraint orders_pk primary key (o_id) )
)
它给了我这些错误
Error(4,64): PLS-00049: bad bind variable 'NEW.O_ID'
Error(5,7): PL/SQL: SQL Statement ignored
Error(5,11): PL/SQL: ORA-00922: missing or invalid option
Error(6,19): PLS-00049: bad bind variable 'NEW.O_ID'
任何可以帮助解决为什么会出现这些错误的帮助都会有所帮助
【问题讨论】:
-
表中产品没有O_ID字段
标签: sql oracle triggers transactions