--本游标是处理 declare cursor c is select JIOYRQ, tjjgh, TJGY, bxgs, sum(jioyje) jioyjesum, count(tbdh) tbdhsum from bx_mir_dsmx WHERE jioyrq = V_SYSDAT group by JIOYRQ, TJGY, tjjgh, bxgs; v_jioyrq t_ls2_tj020_01.jioyrq%type; v_tjjgh t_ls2_tj020_01.tjjgh%type; v_TJGY T_LS2_TJ020_01.TJGY%type; v_bxgs t_ls2_tj020_01.bxgs%type; V_JIOYJESUM T_LS2_tj020_01.JIOYJESUM%TYPE; V_TBDHSUM T_LS2_tj020_01.TBDHSUM%TYPE; /*cursor p is select count(*) khsum from (select distinct tbr,lxdh from bx_mir_dsmx where jioyrq=v_jioyrq and TJGY=v_TJGY and bxgs=v_bxgs);*/ v_khsum t_ls2_tj020_01.khsum%type; begin open c; loop fetch c into v_jioyrq, v_tjjgh, v_TJGY, v_bxgs, V_JIOYJESUM, V_TBDHSUM; exit when c%notfound; --open p; --fetch p into v_khsum; --exit when p%notfound; select count(*) into v_khsum from (select distinct tbr, lxdh from bx_mir_dsmx where jioyrq = v_jioyrq and TJGY = v_TJGY and bxgs = v_bxgs); insert into t_ls2_tj020_01 (jioyrq, TJGY, TJJGH, BXGS, JIOYJESUM, TBDHSUM, khsum) values (v_jioyrq, v_TJGY, v_tjjgh, v_bxgs, V_JIOYJESUM, V_TBDHSUM, v_khsum); commit; --close p; end loop; close c; end;
oracle生产.jio格式,oracle 新的数据库新的change
最新推荐文章于 2024-09-13 14:31:30 发布