SYbase ASAトリガ書き方、ある値が変更されたときに実行文をトリガする
1613 ワード
ALTER TRIGGER "T" AFTER UPDATE OF "approved"
ORDER 3 ON "DBA"."shipper"
referencing new as new_shipper3
FOR EACH ROW /* WHEN( ) */
BEGIN
case when new_shipper3.approved='Y' --
then update DBA.customer set customer.user_7=customer.user_7-(shipper_line.quantity*isnull(part.user_10,0)) from DBA.shipper,DBA.shipper_line,DBA.customer,DBA.part-- "DBA"
where new_shipper3.trans_no=shipper.trans_no and
shipper.trans_no=shipper_line.trans_no and
shipper.customer_id=customer.customer_id and
shipper_line.part_id=part.part_id and
part.product_code ='XQ'
when new_shipper3.approved='N'
then update Dba.customer set customer.user_7=customer.user_7+(shipper_line.quantity*isnull(part.user_10,0)) from dba.shipper,dba.shipper_line,dba.customer,dba.part -- "DBA"
where new_shipper3.trans_no=shipper.trans_no and
shipper.trans_no=shipper_line.trans_no and
shipper.customer_id=customer.customer_id and
shipper_line.part_id=part.part_id and
part.product_code ='XQ'
else
update shipper set
edit_time = getdate(*) where
shipper.trans_no = new_shipper3.trans_no
end case
end