CREATE OR REPLACE PACKAGE BODY ssl AS PROCEDURE insert_ssl(s In ssl_array) AS v_month varchar2(20); v_sql varchar2(5000); v_result number; v_status nu
CREATE OR REPLACE PACKAGE BODY ssl AS PROCEDURE insert_ssl(s In ssl_array) AS v_month varchar2(20); v_sql varchar2(5000); v_result number; v_status number; BEGIN delete from E_TMP_MP_SSL_CURVE; select to_char(s(s.FIRST).data_time,'yyyymm') into v_month from dual; v_result:=-10; FOR i IN s.FIRST .. s.LAST LOOP BEGIN INSERT INTO E_TMP_MP_SSL_CURVE(MPED_ID,DATA_TIME,PS_FLAG,P,PA,PB,PC,Q,QA,QB,QC,UA,UB,UC,IA,IB,IC,COS,COSA,COSB,COSC,PAIA,PAIB,PAIC,PAUA,PAUB,PAUC,SAVEDATETIME,P_COEF,Q_COEF,V_COEF,C_COEF,AREA_CODE,FACTOR_COEF) VALUES (s(i).mped_id, s(i).data_time, s(i).ps_flag, s(i).p ,s(i).pa,s(i). pb,s(i).pc ,s(i).q ,s(i).qa,s(i).qb,s(i).qc, s(i).ua,s(i).ub,s(i).uc,s(i).ia,s(i).ib,s(i).ic, s(i).cos,s(i).cosa,s(i).cosb,s(i).cosc,s(i).paia,s(i).paib,s(i).paic,s(i).paua,s(i).paub,s(i).pauc ,sysdate,1,1,1,1,s(i).AREA_CODE,s(i).FACTOR_COEF); END; END LOOP; v_result:=-20; v_sql := 'delete from E_MP_SSL_CURVE_'||v_month||' a where exists (select 1 from E_TMP_MP_SSL_CURVE b where a.MPED_ID = b.MPED_ID and a.DATA_TIME = b.DATA_TIME and a.PS_FLAG = b.PS_FLAG ) '; execute immediate v_sql; v_result:=-30; v_sql := 'insert into E_MP_SSL_CURVE_'||v_month||' (mped_id, data_time, ps_flag, ua, ub, uc, ia, ib, ic, i0, p, pa, pb, pc, q, qa, qb, qc, cos, cosa, cosb, cosc, sp, spa, spb, spc, fn, paia, paib, paic, paua, paub, pauc, temple, avgp, avgq, p_coef, q_coef, v_coef, c_coef, factor_coef, savedatetime, area_code) select * from E_TMP_MP_SSL_CURVE'; execute immediate v_sql; commit; EXCEPTION WHEN OTHERS THEN begin ROLLBACK; v_status := ERROR_LOG(v_result, SQLCODE, SQLERRM, 'insert_ssl'); end; END insert_ssl; END ssl;