PL/SQL触发器关于删除操作的疑问

Web、Mail、Ftp、DNS、Proxy、VPN、Samba、LDAP 等基础网络服务
回复
头像
Roots
帖子: 662
注册时间: 2005-08-17 19:20

PL/SQL触发器关于删除操作的疑问

#1

帖子 Roots » 2009-11-07 21:26

先上段代码 :em01

代码: 全选

create or replace trigger product_inventory_trg
    after delete or update on bb_basket
    for each row
declare
    cursor basketitem_cur is
        select idproduct, quantity
            from bb_basketitem
            where idbasket=:new.idbasket;
begin
    if updating then
        for basketitem_rec in basketitem_cur loop
        update bb_product
            set stock = stock - basketitem_rec.quantity
            where idproduct = basketitem_rec.idproduct;
        end loop;
    end if;
    
    if deleting then
        for basketitem_rec in basketitem_cur loop
        update bb_product
            set stock = stock + basketitem_rec.quantity
            where idproduct=basketitem_rec.idproduct;
        end loop;
    end if;
end;
疑问是删除操作的时候,会有:new.idbasket么,不是只有:old.idbasket的么
回复