create or replace procedure myNaturalAccount(v_gloviaAccount varchar2, v_acountName varchar2, v_discountAccount varchar2, return_value out int)is n_discountType int;begin if v_gloviaAccount = v_discountAccount then select (max(discounttypeid) + 1) into n_discountType from naturalaccount n; else select n.discounttypeid into n_discountType from naturalaccount n where n.naturalaccountcode=v_discountAccount; end if; insert into naturalaccount (naturalaccountcode, naturalaccountname, discounttypeid) values (v_gloviaAccount, v_acountName, n_discountType); commit; return_value := 1;
exception when others then declare n_sqlcode int := sqlcode; v_sqlerrm varchar2(4000) := sqlerrm; n_errorid int; begin rollback; -- optional step n_errorid := gold_ws_diagnostic.diag_customerrorcode(n_SQLCODE, v_sqlerrm); return_value := n_errorid; end;end myNaturalAccount;