create or replace TRIGGER FORMSON_0021_I 
before INSERT ON seeyon.formson_0021
for each row
declare  
  F_ID NUMBER(19,0) :=0;
  f_id_10 decimal(20,2);
  PRAGMA AUTONOMOUS_TRANSACTION; 
BEGIN
  IF INSERTING THEN
      select id into F_ID from formson_0021 where sort=:new.sort-1 and FORMMAIN_ID=:new.FORMMAIN_ID;
      IF F_ID > 0 THEN
        select field0010 into f_id_10 from formson_0021 where id =F_ID;
         IF :new.field0009 is not null THEN
              :new.FIELD0010 :=f_id_10+:new.field0009;
          END IF;
          IF :new.field0013 is not null THEN
               :new.FIELD0010 :=f_id_10-:new.field0013;
          END IF;
        END IF;
      END IF;
      COMMIT; 
END;