主题:触发器??
求救!纠正触发器!
商品表
create table system.product
(product_id number(10) primary key,
product_name char(30) not null,
quantity number(5),
price number(5));
采购表
create table SYSTEM.purchase(
product_ID number(10) primary key,
purchase_quantity number(5) not null);
当产品数量小于10时,触发器实现自动生成采购记录!
create or replace trigger add_pur
after update on system.product for each row
declare
n number;
begin
select quantity into n
from system.product where product_id=:new.product_id;
dbms_output.put_line(n);
if n<10 then
insert into system.purchase values(:new.product_id,300);
end if;
end add_pur;