PL/SQL存储过程-中国电力负荷数据存储功能-仅供参考

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;

 

转载于:https://www.cnblogs.com/Jepson1218/p/5179486.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值