create or replace trigger biufer_bxfy
after insert or update of bxzfy
on bxfy
FOR EACH ROW
declare
  cnt number(10):=0;
begin
  IF INSERTING THEN
    SELECT COUNT(*) INTO CNT FROM baoxiao WHERE id=:new.sid;
    IF CNT=0 THEN
      INSERT INTO baoxiao (fysum,...) values(:new.bxzfy,...);
    ELSE
      update baoxiao set fysum = fysum + :new.bxzfy;
    END IF;
  ELSIF UPDATING THEN
    --记录增量
    update baoxiao set fysum = fysum + :new.bxzfy - :old.bxzfy where id=:new.sid;
  END IF;
end;