我用的是oracle10g下面是我打印出来的源码:create or replace trigger TG_TBB_ARTICLE_U_BEFORE
BEFORE update
on Tbb_Article
for each row
declare
begin
update Tbb_SaleArticle
set UseStatus = :NEW.UseStatus
where :NEW.UseStatus <> :OLD.UseStatus
and Tbb_SaleArticle.ArtiId = :NEW.ArtiId
and InclQty<>1;
update Tbb_ImpArticle
set UseStatus = :NEW.UseStatus
where :NEW.UseStatus <> :OLD.UseStatus
and Tbb_ImpArticle.ArtiId = :NEW.ArtiId;
case
when updating('RETAILSALEPRICE') or updating('RetailPrice') then
update Tbb_SaleArticle
set SALEARTISPELL = :NEW.ARTISPELL||'/'||RETAILSALEPRICE
where ArtiId = :NEW.ArtiId;
:NEW.ARTISPELL := :NEW.ARTISPELL||'/'||:NEW.RetailPrice;
else
null;
end case;
update Tbb_SaleArticle
set SALEARTINAME = :NEW.ARTINAME,
SALEARTIABBR = :NEW.ARTIABBR,
SALEARTIFACTORYCODE = :NEW.ARTIFACTORYCODE,
SALEMANUFACTORY = :NEW.MANUFACTORY,
SALEPROCESSPRICE = case when InclQty = 1 then :NEW.PROCESSPRICE else case when InclQty > 0 then round(:NEW.PROCESSPRICE *InclQty,6) else -round(:NEW.PROCESSPRICE / (case when nvl(InclQty,0) = 0 then 1 else InclQty end),4) end end ,
SALESTAXRATE = :NEW.STAXRATE--,
-- SALEARTILIMIT = case when InclQty = 1 then :NEW.ARTILIMIT else case when InclQty > 0 then round(:NEW.ARTILIMIT *InclQty,4) else -round(:NEW.ARTILIMIT / InclQty,4) end end
where ArtiId = :NEW.ArtiId;
case
when updating('RetailPrice') then
update Tbb_SaleArticle
set RetailSalePrice = :NEW.RetailPrice,
ModifyDate = getdate()
where Tbb_SaleArticle.ArtiId = :NEW.ArtiId
and InclQty = 1;
if nvl(:NEW.AgioPrice,0) = 0 then
update Tbb_ArticleAdd
set RetailPriceAdd = :NEW.RetailPrice
where Tbb_ArticleAdd.ArtiId =:NEW.ArtiId;
end if;
update Tbb_SaleArticle
set RetailSalePrice = case when InclQty > 0 then round(:NEW.RetailPrice *InclQty,6) else -round(:NEW.RetailPrice / (case when InclQty = 0 then 1 else InclQty end),6) end,
ModifyDate = getdate()
where Tbb_SaleArticle.ArtiId = :NEW.ArtiId
and InclQty <> 1;
else
null;
end case;
case
when updating('AgioPrice') then
update Tbb_SaleArticle
set AgioSalePrice = :NEW.AgioPrice,
ModifyDate = getdate()
where Tbb_SaleArticle.ArtiId = :NEW.ArtiId
and InclQty = 1;
if :NEW.AgioPrice > 0 then
update Tbb_ArticleAdd
set RetailPriceAdd = :NEW.AgioPrice
where Tbb_ArticleAdd.ArtiId =:NEW.ArtiId;
end if;
update Tbb_SaleArticle
set AgioSalePrice = case when InclQty > 0 then round(:NEW.AgioPrice *InclQty,6) else -round(:NEW.AgioPrice / (case when InclQty = 0 then 1 else InclQty end),6) end,
ModifyDate = getdate()
where Tbb_SaleArticle.ArtiId = :NEW.ArtiId
and InclQty <> 1;
else
null;
end case;
case
when updating('AwardAmt') then
update Tbb_SaleArticle
set AwardAmt = :NEW.AwardAmt,
ModifyDate = getdate()
where Tbb_SaleArticle.ArtiId = :NEW.ArtiId
and InclQty = 1;
update Tbb_SaleArticle
set AwardAmt = case when InclQty > 0 then round(:NEW.AwardAmt *InclQty,6) else -round(:NEW.AwardAmt / (case when InclQty = 0 then 1 else InclQty end),6) end,
ModifyDate = getdate()
where Tbb_SaleArticle.ArtiId = :NEW.ArtiId
and InclQty <> 1;
else
null;
end case;
case
when updating('CostPrice') then
update Tbb_SaleArticle
set SaleCostPrice = :NEW.CostPrice,
ModifyDate = getdate()
where Tbb_SaleArticle.ArtiId = :NEW.ArtiId
and InclQty = 1;
update Tbb_SaleArticle
set SaleCostPrice = case when InclQty > 0 then round(:NEW.CostPrice *InclQty,6) else -round(:NEW.CostPrice / (case when InclQty = 0 then 1 else InclQty end),6) end,
ModifyDate = getdate()
where Tbb_SaleArticle.ArtiId = :NEW.ArtiId
and InclQty <> 1;
else
null;
end case;
case
when updating('UseStatus') then
if :NEW.UseStatus<>100 then
update Tbb_SaleArticle
set UseStatus = :NEW.UseStatus
where ArtiId = :NEW.ArtiId
and InclQty<>1;
end if;
update Tbb_ImpArticle
set UseStatus = :NEW.UseStatus
where ArtiId = :NEW.ArtiId;
update Tbb_UsedArtiInfo
set UseStatus = :NEW.UseStatus
where ArtiId = :NEW.ArtiId;
if :NEW.UseStatus = 110 then
update Tbd_StkCell
set ArtiId = 0, UseStatus = 0
where ArtiId = :NEW.ArtiId;
elsif :NEW.UseStatus =0 and :OLD.UseStatus=200 then
update Tbb_UsedArtiInfo
set CheckDate = getdate()
where ArtiId = :NEW.ArtiId;
elsif :NEW.UseStatus =110 and :OLD.UseStatus=0 then
update Tbb_UsedArtiInfo
set DisDate = getdate()
where ArtiId = :NEW.ArtiId;
end if;
else
null;
end case;
end;