<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "运行年月收发存">
<query id = "FrmRunTimeRptZg.getOriginalLast" desc = "获取期初重量">
<![CDATA[
select t.JUDGE_STOVE_NO,t.BATCH_NO,t.BATCH_GROUD_NO,
                    sum(nvl(t.ACT_COUNT,0))count,
                    sum(nvl(t.ACT_WEIGHT, 0)) weight
                    from ydm_zc_initial_zg t
                    where 1=1 and  t.BAL_YEAR_MONTH LIKE '%'||?||'%' 
                     #condtions#
                    
                    ]]>
</query>
<query id = "FrmRunTimeRptZg.getThisIn" desc = "本期入库量">
<![CDATA[
                     select t.JUDGE_STOVE_NO,t.BATCH_NO,t.BATCH_GROUD_NO,
                                   nvl(sum(case
                                        when t.BAL_YEAR_MONTH = ? then
                                         nvl(t.count, 0)
                                      end),
                                   0) weight_monthcount,
                              nvl(sum(case
                                        when t.BAL_YEAR_MONTH = ? then
                                         nvl(t.weight, 0)
                                      end),
                                   0) weight_month  
                          from (select t.JUDGE_STOVE_NO,t.BATCH_NO,t.BATCH_GROUD_NO,t.BELONG_CODE,
                                     t.BAL_YEAR_MONTH,  
                                      nvl(t.ACT_COUNT,0)count,
                                       nvl(t.ACT_WEIGHT, 0) weight,
                                       t.STORAGE_NO
                                  from ydm_zc_inlist t
                                 where t.validflag = '1'
                                  and t.INSTOCK_TYPE_CODE in ('800701','800702','800703','800704','800705','800707')
                                  and t.BAL_YEAR_MONTH = ?
                                  AND T.QCM_STAUS IN('00','11','22')
                                  --AND t.JUDGE_STOVE_NO ='572049'
                                    #condtions# 
                                   )t where 1=1
                                   
                             ]]>
</query>
<query id = "FrmRunTimeRptZg.getThisInB" desc = "本期入库量(所属权)">
<![CDATA[
                     select t.JUDGE_STOVE_NO,t.BATCH_NO,t.BATCH_GROUD_NO,
                                   nvl(sum(case
                                        when t.BAL_YEAR_MONTH = ? then
                                         nvl(t.count, 0)
                                      end),
                                   0) weight_monthcount,
                              nvl(sum(case
                                        when t.BAL_YEAR_MONTH = ? then
                                         nvl(t.weight, 0)
                                      end),
                                   0) weight_month  
                          from (select t.JUDGE_STOVE_NO,t.BATCH_NO,t.BATCH_GROUD_NO,t.BELONG_CODE,
                                     t.BAL_YEAR_MONTH,  
                                      nvl(t.ACT_COUNT,0)count,
                                       nvl(t.ACT_WEIGHT, 0) weight,
                                       t.STORAGE_NO
                                  from ydm_zc_inlist t
                                 where t.INSTOCK_TYPE_CODE in ('800701','800702','800704','800706','800707')
                                  and t.BAL_YEAR_MONTH = ?
                                  --AND t.JUDGE_STOVE_NO ='572049'
                                    AND T.QCM_STAUS IN ('00', '11','22')
                                    #condtions# 
                                   )t where 1=1
                                   
                             ]]>
</query>
<query id = "FrmRunTimeRptZg.getThisOut" desc = "本期出库量">
<![CDATA[
                      select t.JUDGE_STOVE_NO,t.BATCH_NO,t.BATCH_GROUD_NO,
                                  nvl(sum(case
                                         when t.BAL_YEAR_MONTH = ? then
                                         nvl(t.count, 0)
                                      end),
                                  0) weight_monthcount,
                              nvl(sum(case
                                         when t.BAL_YEAR_MONTH = ? then
                                         nvl(t.weight, 0)
                                      end),
                                  0) weight_month
                         from (select t.JUDGE_STOVE_NO,t.BATCH_NO,t.BATCH_GROUD_NO,t.BELONG_CODE,
                         t.BAL_YEAR_MONTH,
                                    nvl(t.ACT_COUNT,0)count,
                                    t.STORAGE_NO,
                                    case when t.PONDER_NO is null
                                       then nvl(t.ACT_WEIGHT, 0)
                                       else nvl(t.PONDER_GROSS_WT, 0) end as weight
                             from ydm_zc_outlist t
                           where 
                               t.OUTSTOCK_TYPE_CODE in ('800805','800804','800802','800808','800806','800803')
                               and t.BAL_YEAR_MONTH = ?
                               --and t.JUDGE_STOVE_NO = '572049'
                                     #condtions# 
                             )t where 1=1
                             
                             ]]>
</query>
<query id = "FrmRunTimeRptZg.getThisOutB" desc = "本期出库量(所属权)">
<![CDATA[
                      select t.JUDGE_STOVE_NO,t.BATCH_NO,t.BATCH_GROUD_NO,
                                  nvl(sum(case
                                         when t.BAL_YEAR_MONTH = ? then
                                         nvl(t.count, 0)
                                      end),
                                  0) weight_monthcount,
                              nvl(sum(case
                                         when t.BAL_YEAR_MONTH = ? then
                                         nvl(t.weight, 0)
                                      end),
                                  0) weight_month
                         from (select t.JUDGE_STOVE_NO,t.BATCH_NO,t.BATCH_GROUD_NO,t.BELONG_CODE,
                         t.BAL_YEAR_MONTH,
                                    nvl(t.ACT_COUNT,0)count,
                                    t.STORAGE_NO,
                                    case when t.PONDER_NO is null
                                       then nvl(t.ACT_WEIGHT, 0)
                                       else nvl(t.PONDER_GROSS_WT, 0) end as weight
                             from ydm_zc_outlist t
                           where 
                               t.OUTSTOCK_TYPE_CODE in ('800801','800806','800809','800810')
                               and t.validflag = '1'
                               and t.BAL_YEAR_MONTH = ?
                               --and t.JUDGE_STOVE_NO = '572049'
                                     #condtions# 
                             )t where 1=1
                             
                             ]]>
</query>

<query id = "FrmRunTimeRpt.SelectMatZc" desc = "查询库存信息">
<![CDATA[
	SELECT
  sum(T.Act_Count)Act_Count,
  sum(T.Act_Weight)Act_Weight,
       T.BELONG_CODE,
       T.BELONG_NAME
       --T.Ord_Pk,
       --T.Ord_Ln_Pk,
       --T.Ord_Ln_Dly_Pk
  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS B
  LEFT JOIN YDM_BS_STORAGE C ON C.STORAGE_NO = B.STORAGE_NO
 WHERE T.MAT_NO = B.MAT_NO
   AND T.JUDGE_STOVE_NO =  ?
   AND T.BATCH_NO = ?
   AND T.BATCH_GROUD_NO = ?
   group by T.BELONG_CODE,
       T.BELONG_NAME
       --T.Ord_Pk,
       --T.Ord_Ln_Pk,
       --T.Ord_Ln_Dly_Pk
   
   ]]>
</query>
<query id = "FrmRunTimeRpt.selectInitalMat" desc = "查询材料信息">
SELECT sum(T.Act_Count) Act_Count,
       sum(T.Act_Weight) Act_Weight,
       sum(T.ACT_LEN) ACT_LEN,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       max(T.ACT_LEN_MIN) ACT_LEN_MIN,
       max(T.ACT_LEN_MAX) ACT_LEN_MAX,
       T.BELONG_CODE,
       T.BELONG_NAME,
       max(TO_CHAR(T.INSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS')) INSTOCK_TIME,
       T.MEMO,
       
       T.JUDGE_STD_NAME,
       T.PIPMEMO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
      
       T.PLINE_CODE,
       T.PLINE_NAME,
       max(B.STORAGE_NO)STORAGE_NO
  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS B
  LEFT JOIN YDM_BS_STORAGE C ON C.STORAGE_NO = B.STORAGE_NO
 WHERE T.MAT_NO = B.MAT_NO
   AND T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.BATCH_GROUD_NO = ?
 group by T.ACT_DIMATER,
          T.ACT_HEIGHT,
          T.BELONG_CODE,
          T.BELONG_NAME,
          T.MEMO,
          T.JUDGE_STD_NAME,
          T.PIPMEMO,
          T.JUDGE_STOVE_NO,
          T.BATCH_NO,
          T.BATCH_GROUD_NO,
          T.MATERIAL_NO,
          T.MATERIAL_NAME,
          T.PRODUCCODE,
          T.PRODUCNAME,
          T.STEELCODE,
          T.STEELNAME,
          T.GRADECODE,
          T.GRADENAME,
          T.SPEC_CODE,
          T.SPEC_NAME,
          T.MODEL_CODE,
          T.MODEL_DESC,
          T.STD_CODE,
          T.STD_NAME,
          T.STD_STYLE,
          T.STD_STYLE_DESC,
          T.PLINE_CODE,
          T.PLINE_NAME
          --B.STORAGE_NO
</query>
<query id = "FrmRunTimeRptZg.getIntalJZ" desc = "查询是否已存在结转年月的结转数据了">
SELECT COUNT(1) ACOUNT
  FROM YDM_ZC_INITIAL_ZG T
 WHERE T.BAL_YEAR_MONTH = ?
</query>
<query id = "FrmRunTimeRptZg.insertInital_" desc = "结转插入">
<![CDATA[
declare
  v_Act_count   mat_zc_m.act_count%type :=null;
  v_Act_Weight  mat_zc_m.act_weight%type:= null;
  v_ACT_LEN     mat_zc_m.act_len%type:= null;
  v_ACT_DIMATER mat_zc_m.act_dimater%type:= null;
  v_ACT_HEIGHT mat_zc_m.act_height%type := null;
  v_ACT_LEN_MIN mat_zc_m.act_len_min%type := null;
  v_ACT_LEN_MAX mat_zc_m.act_len_max%type := null;
  v_INSTOCK_TIME mat_zc_m.instock_time%type := null;
  v_MEMO mat_zc_m.memo%type := null;
  v_JUDGE_STD_NAME mat_zc_m.judge_std_name%type := null;
  v_PIPMEMO mat_zc_m.pipmemo%type := null;
  v_MATERIAL_NO mat_zc_m.material_no%type := null;
  v_MATERIAL_NAME mat_zc_m.material_name%type := null;
  v_PRODUCCODE mat_zc_m.produccode%type := null;
  v_PRODUCNAME mat_zc_m.producname%type := null;
  v_STEELCODE mat_zc_m.steelcode%type := null;
  v_STEELNAME mat_zc_m.steelname%type := null;
  v_GRADECODE mat_zc_m.gradecode%type := null;
  v_GRADENAME mat_zc_m.gradename%type := null;
  v_SPEC_CODE mat_zc_m.spec_code%type := null;
  v_SPEC_NAME mat_zc_m.spec_name%type := null;
  v_MODEL_CODE mat_zc_m.model_code%type := null;
  v_MODEL_DESC mat_zc_m.model_desc%type := null;
  v_STD_CODE mat_zc_m.std_code%type := null;
  v_STD_NAME mat_zc_m.std_name%type := null;
  v_STD_STYLE mat_zc_m.std_style%type := null;
  v_STD_STYLE_DESC mat_zc_m.std_style_desc%type := null;
  v_PLINE_CODE mat_zc_m.pline_code%type := null;
  v_PLINE_NAME mat_zc_m.pline_name%type := null;
  v_STORAGE_NO ydm_zc_buttress.storage_no%type := null;
  v_BELONG_CODE mat_zc_m.BELONG_CODE%type := null;
  v_BELONG_NAME mat_zc_m.BELONG_NAME%type := null;
  v_count number :=0;
begin
 SELECT count(1) into v_count FROM MAT_ZC_M T, YDM_ZC_BUTTRESS B
 WHERE T.MAT_NO = B.MAT_NO
   AND T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.BATCH_GROUD_NO = ?
   --AND T.BELONG_CODE IN ('100101','100102','100103')
   AND ROWNUM = 1
 group by T.ACT_DIMATER,
          T.ACT_HEIGHT,
          T.MEMO,
          T.JUDGE_STD_NAME,
          T.PIPMEMO,
          T.MATERIAL_NO,
          T.MATERIAL_NAME,
          T.PRODUCCODE,
          T.PRODUCNAME,
          T.STEELCODE,
          T.STEELNAME,
          T.GRADECODE,
          T.GRADENAME,
          T.SPEC_CODE,
          T.SPEC_NAME,
          T.MODEL_CODE,
          T.MODEL_DESC,
          T.STD_CODE,
          T.STD_NAME,
          T.STD_STYLE,
          T.STD_STYLE_DESC,
          T.PLINE_CODE,
          T.PLINE_NAME;
          if v_count > 0 then 
SELECT sum(T.Act_Count) Act_Count,
       sum(T.Act_Weight) Act_Weight,
       sum(T.ACT_LEN) ACT_LEN,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       max(T.ACT_LEN_MIN) ACT_LEN_MIN,
       max(T.ACT_LEN_MAX) ACT_LEN_MAX,
       max(T.INSTOCK_TIME) INSTOCK_TIME,
       T.MEMO,
       T.JUDGE_STD_NAME,
       T.PIPMEMO,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.PLINE_CODE,
       T.PLINE_NAME,
       max(B.STORAGE_NO) STORAGE_NO,
       T.BELONG_CODE,
       T.BELONG_NAME
       into v_Act_count,v_Act_Weight,v_ACT_LEN,v_ACT_DIMATER,v_ACT_HEIGHT,v_ACT_LEN_MIN,v_ACT_LEN_MAX,v_INSTOCK_TIME,
  v_MEMO,
  v_JUDGE_STD_NAME ,
  v_PIPMEMO ,
  v_MATERIAL_NO ,
  v_MATERIAL_NAME ,
  v_PRODUCCODE ,
  v_PRODUCNAME ,
  v_STEELCODE ,
  v_STEELNAME ,
  v_GRADECODE ,
  v_GRADENAME ,
  v_SPEC_CODE ,
  v_SPEC_NAME ,
  v_MODEL_CODE,
  v_MODEL_DESC ,
  v_STD_CODE ,
  v_STD_NAME ,
  v_STD_STYLE ,
  v_STD_STYLE_DESC ,
  v_PLINE_CODE ,
  v_PLINE_NAME,
  v_STORAGE_NO,
  v_BELONG_CODE,
  v_BELONG_NAME
  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS B
 WHERE T.MAT_NO = B.MAT_NO
   AND T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.BATCH_GROUD_NO = ?
   --AND T.BELONG_CODE IN ('100101','100102','100103')
   AND ROWNUM = 1
 group by T.ACT_DIMATER,
          T.ACT_HEIGHT,
          T.MEMO,
          T.JUDGE_STD_NAME,
          T.PIPMEMO,
          T.MATERIAL_NO,
          T.MATERIAL_NAME,
          T.PRODUCCODE,
          T.PRODUCNAME,
          T.STEELCODE,
          T.STEELNAME,
          T.GRADECODE,
          T.GRADENAME,
          T.SPEC_CODE,
          T.SPEC_NAME,
          T.MODEL_CODE,
          T.MODEL_DESC,
          T.STD_CODE,
          T.STD_NAME,
          T.STD_STYLE,
          T.STD_STYLE_DESC,
          T.PLINE_CODE,
          T.PLINE_NAME,
          T.BELONG_CODE,
          T.BELONG_NAME;
        else
      SELECT sum(T.Act_Count) Act_Count,
       sum(T.Act_Weight) Act_Weight,
       sum(T.ACT_LEN) ACT_LEN,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       max(T.ACT_LEN_MIN) ACT_LEN_MIN,
       max(T.ACT_LEN_MAX) ACT_LEN_MAX,
       max(T.INSTOCK_TIME) INSTOCK_TIME,
       T.MEMO,
       T.JUDGE_STD_NAME,
       T.PIPMEMO,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.PLINE_CODE,
       T.PLINE_NAME
       into v_Act_count,v_Act_Weight,v_ACT_LEN,v_ACT_DIMATER,v_ACT_HEIGHT,v_ACT_LEN_MIN,v_ACT_LEN_MAX,v_INSTOCK_TIME,
  v_MEMO,
  v_JUDGE_STD_NAME ,
  v_PIPMEMO ,
  v_MATERIAL_NO ,
  v_MATERIAL_NAME ,
  v_PRODUCCODE ,
  v_PRODUCNAME ,
  v_STEELCODE ,
  v_STEELNAME ,
  v_GRADECODE ,
  v_GRADENAME ,
  v_SPEC_CODE ,
  v_SPEC_NAME ,
  v_MODEL_CODE,
  v_MODEL_DESC ,
  v_STD_CODE ,
  v_STD_NAME ,
  v_STD_STYLE ,
  v_STD_STYLE_DESC ,
  v_PLINE_CODE ,
  v_PLINE_NAME
  
  FROM MAT_ZC_M T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.BATCH_GROUD_NO = ?
   
   AND ROWNUM = 1
 group by T.ACT_DIMATER,
          T.ACT_HEIGHT,
          T.MEMO,
          T.JUDGE_STD_NAME,
          T.PIPMEMO,
          T.MATERIAL_NO,
          T.MATERIAL_NAME,
          T.PRODUCCODE,
          T.PRODUCNAME,
          T.STEELCODE,
          T.STEELNAME,
          T.GRADECODE,
          T.GRADENAME,
          T.SPEC_CODE,
          T.SPEC_NAME,
          T.MODEL_CODE,
          T.MODEL_DESC,
          T.STD_CODE,
          T.STD_NAME,
          T.STD_STYLE,
          T.STD_STYLE_DESC,
          T.PLINE_CODE,
          T.PLINE_NAME;
          end if;  
  INSERT INTO YDM_ZC_INITIAL_ZG(
        JUDGE_STD_NAME,
        INSTOCK_TIME,
        BELONG_CODE,
        BELONG_NAME,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BATCH_GROUD_NO,
        MATERIAL_NO,
        MATERIAL_NAME,
        PRODUCCODE,
        PRODUCNAME,
        STEELCODE,
        STEELNAME,
        SPEC_CODE,
        SPEC_NAME,
        MODEL_CODE,
        MODEL_DESC,
        STD_CODE,
        STD_NAME,
        STD_STYLE,
        STD_STYLE_DESC,
        DIMATER,
        HEIGHT,
        LEN,
        LEN_MIN,
        LEN_MAX,
        ACT_COUNT,
        ACT_WEIGHT,
        STORAGE_NO,
        MEMO,
        CREATE_NAME,
        CREATE_TIME,
        ORIGINAL_DATE,
        BAL_YEAR_MONTH,
        GRADECODE,
        GRADENAME,
        PLINE_CODE,
        PLINE_NAME,
        HANDLE_LOG)
 VALUES( 
        v_JUDGE_STD_NAME,
        v_INSTOCK_TIME,
        v_BELONG_CODE,
        v_BELONG_NAME,
        ?,
        ?,
        ?,
        v_MATERIAL_NO,
        v_MATERIAL_NAME,
        v_PRODUCCODE,
        v_PRODUCNAME,
        v_STEELCODE,
        v_STEELNAME,
        v_SPEC_CODE,
        v_SPEC_NAME,
        v_MODEL_CODE,
        v_MODEL_DESC,
        v_STD_CODE,
        v_STD_NAME,
        v_STD_STYLE,
        v_STD_STYLE_DESC,
        nvl(v_ACT_DIMATER,'0'),
        nvl(v_ACT_HEIGHT,'0'),
        nvl(v_ACT_LEN,'0'),
        nvl(v_ACT_LEN_MIN,'0'),
        nvl(v_ACT_LEN_MAX,'0'),
        nvl(?,'0'),
        nvl(?,'0'),
        v_STORAGE_NO,
        v_MEMO,
        ?,
        SYSDATE,
        ?,
        ?,
        v_GRADECODE,
        v_GRADENAME,
        v_PLINE_CODE,
        v_PLINE_NAME,
        ?
        );
  end;
]]>
</query>
<query id = "FrmRunTimeRptZg.insertInitalBelog1" desc = "结转(所属权)">
DECLARE

BEGIN
FOR MYROW IN (SELECT    SUM(T.ACT_LEN)ACT_LEN,
                        T.MATERIAL_NO,
                        T.MATERIAL_NAME,
                        T.PRODUCCODE,
                        T.PRODUCNAME,
                        T.STEELCODE,
                        T.STEELNAME,
                        T.GRADECODE,
                        T.GRADENAME,
                        T.SPEC_CODE,
                        T.SPEC_NAME,
                        T.MODEL_CODE,
                        T.MODEL_DESC,
                        T.STD_CODE,
                        T.STD_NAME,
                        T.STD_STYLE,
                        T.STD_STYLE_DESC,
                        T.PLINE_CODE,
                        T.PLINE_NAME,
                        T.ACT_DIMATER,
                        T.ACT_HEIGHT,
                        T.ACT_LEN_MIN,
                        T.ACT_LEN_MAX,
                        T.MEMO,
                        T.JUDGE_STD_NAME,
                        T.PIPMEMO,
                        T.BELONG_CODE,
                        T.BELONG_NAME,
                        S.STORAGE_NO
                FROM MAT_ZC_M T,YDM_ZC_BUTTRESS S
               WHERE T.MAT_NO = S.MAT_NO
                 AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                 AND T.BATCH_NO = '#BATCH_NO#'
                 AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
                 AND T.BELONG_CODE LIKE '#BELONG_CODE#%'
                 AND ROWNUM = 1
               GROUP BY T.MATERIAL_NO,
                        T.MATERIAL_NAME,
                        T.PRODUCCODE,
                        T.PRODUCNAME,
                        T.STEELCODE,
                        T.STEELNAME,
                        T.GRADECODE,
                        T.GRADENAME,
                        T.SPEC_CODE,
                        T.SPEC_NAME,
                        T.MODEL_CODE,
                        T.MODEL_DESC,
                        T.STD_CODE,
                        T.STD_NAME,
                        T.STD_STYLE,
                        T.STD_STYLE_DESC,
                        T.PLINE_CODE,
                        T.PLINE_NAME,
                        T.ACT_DIMATER,
                        T.ACT_HEIGHT,
                        T.ACT_LEN_MIN,
                        T.ACT_LEN_MAX,
                        T.MEMO,
                        T.JUDGE_STD_NAME,
                        T.PIPMEMO,
                        T.BELONG_CODE,
                        T.BELONG_NAME,
                        S.STORAGE_NO) LOOP
                        INSERT INTO YDM_ZC_INITIAL_ZG(
        JUDGE_STD_NAME,
        INSTOCK_TIME,
        BELONG_CODE,
        BELONG_NAME,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BATCH_GROUD_NO,
        MATERIAL_NO,
        MATERIAL_NAME,
        PRODUCCODE,
        PRODUCNAME,
        STEELCODE,
        STEELNAME,
        SPEC_CODE,
        SPEC_NAME,
        MODEL_CODE,
        MODEL_DESC,
        STD_CODE,
        STD_NAME,
        STD_STYLE,
        STD_STYLE_DESC,
        DIMATER,
        HEIGHT,
        LEN,
        LEN_MIN,
        LEN_MAX,
        ACT_COUNT,
        ACT_WEIGHT,
        STORAGE_NO,
        MEMO,
        CREATE_NAME,
        CREATE_TIME,
        ORIGINAL_DATE,
        BAL_YEAR_MONTH,
        GRADECODE,
        GRADENAME,
        PLINE_CODE,
        PLINE_NAME,
        HANDLE_LOG
        )
 VALUES( 
        MYROW.JUDGE_STD_NAME,
        TO_DATE('#INSTOCK_TIME#','YYYY-MM-DD HH24:MI:SS'),
        MYROW.BELONG_CODE,
        MYROW.BELONG_NAME,
        '#JUDGE_STOVE_NO#',
        '#BATCH_NO#',
        '#BATCH_GROUD_NO#',
        MYROW.MATERIAL_NO,
        MYROW.MATERIAL_NAME,
        MYROW.PRODUCCODE,
        MYROW.PRODUCNAME,
        MYROW.STEELCODE,
        MYROW.STEELNAME,
        MYROW.SPEC_CODE,
        MYROW.SPEC_NAME,
        MYROW.MODEL_CODE,
        MYROW.MODEL_DESC,
        MYROW.STD_CODE,
        MYROW.STD_NAME,
        MYROW.STD_STYLE,
        MYROW.STD_STYLE_DESC,
        MYROW.ACT_DIMATER,
        MYROW.ACT_HEIGHT,
        MYROW.ACT_LEN,
        MYROW.ACT_LEN_MIN,
        MYROW.ACT_LEN_MAX,
        '#ACT_COUNT#',
        '#ACT_WEIGHT#',
        MYROW.STORAGE_NO,
        MYROW.MEMO,
        '#CREATE_NAME#',
        TO_DATE('#INSTOCK_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '',
        '#BAL_YEAR_MONTH#',
        MYROW.GRADECODE,
        MYROW.GRADENAME,
        MYROW.PLINE_CODE,
        MYROW.PLINE_NAME,
        '1');
    END LOOP;
END;
</query>
<query id = "FrmRunTimeRptZg.insertInitalBelog" desc = "结转(所属权)">
                        INSERT INTO YDM_ZC_INITIAL_ZG(
        JUDGE_STD_NAME,
        INSTOCK_TIME,
        BELONG_CODE,
        BELONG_NAME,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BATCH_GROUD_NO,
        MATERIAL_NO,
        MATERIAL_NAME,
        PRODUCCODE,
        PRODUCNAME,
        STEELCODE,
        STEELNAME,
        SPEC_CODE,
        SPEC_NAME,
        MODEL_CODE,
        MODEL_DESC,
        STD_CODE,
        STD_NAME,
        STD_STYLE,
        STD_STYLE_DESC,
        DIMATER,
        HEIGHT,
        LEN,
        LEN_MIN,
        LEN_MAX,
        ACT_COUNT,
        ACT_WEIGHT,
        STORAGE_NO,
        MEMO,
        CREATE_NAME,
        CREATE_TIME,
        ORIGINAL_DATE,
        BAL_YEAR_MONTH,
        GRADECODE,
        GRADENAME,
        PLINE_CODE,
        PLINE_NAME,
        HANDLE_LOG
        )
 VALUES( 
        '#JUDGE_STD_NAME#',
        TO_DATE('#INSTOCK_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#BELONG_CODE#',
        '#BELONG_NAME#',
        '#JUDGE_STOVE_NO#',
        '#BATCH_NO#',
        '#BATCH_GROUD_NO#',
        '#MATERIAL_NO#',
        '#MATERIAL_NAME#',
        '#PRODUCCODE#',
        '#PRODUCNAME#',
        '#STEELCODE#',
        '#STEELNAME#',
        '#SPEC_CODE#',
        '#SPEC_NAME#',
        '#MODEL_CODE#',
        '#MODEL_DESC#',
        '#STD_CODE#',
        '#STD_NAME#',
        '#STD_STYLE#',
        '#STD_STYLE_DESC#',
        '#ACT_DIMATER#',
        '#ACT_HEIGHT#',
        '#ACT_LEN#',
        '#ACT_LEN_MIN#',
        '#ACT_LEN_MAX#',
        '#ACT_COUNT#',
        '#ACT_WEIGHT#',
        '#STORAGE_NO#',
        '#MEMO#',
        '#CREATE_NAME#',
        TO_DATE('#INSTOCK_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '',
        '#BAL_YEAR_MONTH#',
        '#GRADECODE#',
        '#GRADENAME#',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        '1')
</query>
<query id = "FrmRunTimeRptZg.SelectInitalBelog" desc= "查询基本信息">
<![CDATA[
SELECT    SUM(T.ACT_LEN)ACT_LEN,
                        T.MATERIAL_NO,
                        T.MATERIAL_NAME,
                        T.PRODUCCODE,
                        T.PRODUCNAME,
                        T.STEELCODE,
                        T.STEELNAME,
                        T.GRADECODE,
                        T.GRADENAME,
                        T.SPEC_CODE,
                        T.SPEC_NAME,
                        T.MODEL_CODE,
                        T.MODEL_DESC,
                        T.STD_CODE,
                        T.STD_NAME,
                        T.STD_STYLE,
                        T.STD_STYLE_DESC,
                        T.PLINE_CODE,
                        T.PLINE_NAME,
                        T.ACT_DIMATER,
                        T.ACT_HEIGHT,
                        T.ACT_LEN_MIN,
                        T.ACT_LEN_MAX,
                        T.MEMO,
                        T.JUDGE_STD_NAME,
                        T.PIPMEMO,
                        T.BELONG_CODE,
                        T.BELONG_NAME,
                        S.STORAGE_NO
                FROM MAT_ZC_M T,YDM_ZC_BUTTRESS S
               WHERE T.MAT_NO = S.MAT_NO
                 AND T.JUDGE_STOVE_NO = ?
                 AND T.BATCH_NO = ?
                 AND T.BATCH_GROUD_NO = ?
                 AND T.BELONG_CODE || '&' LIKE ('%' || ? || '%')
                 AND ROWNUM = 1
               GROUP BY T.MATERIAL_NO,
                        T.MATERIAL_NAME,
                        T.PRODUCCODE,
                        T.PRODUCNAME,
                        T.STEELCODE,
                        T.STEELNAME,
                        T.GRADECODE,
                        T.GRADENAME,
                        T.SPEC_CODE,
                        T.SPEC_NAME,
                        T.MODEL_CODE,
                        T.MODEL_DESC,
                        T.STD_CODE,
                        T.STD_NAME,
                        T.STD_STYLE,
                        T.STD_STYLE_DESC,
                        T.PLINE_CODE,
                        T.PLINE_NAME,
                        T.ACT_DIMATER,
                        T.ACT_HEIGHT,
                        T.ACT_LEN_MIN,
                        T.ACT_LEN_MAX,
                        T.MEMO,
                        T.JUDGE_STD_NAME,
                        T.PIPMEMO,
                        T.BELONG_CODE,
                        T.BELONG_NAME,
                        S.STORAGE_NO
                        ]]>
</query>
<query id = "FrmRunTimeRptZg.SelectMat" desc = "查询是否存在库存">
<![CDATA[
SELECT COUNT(1) AS ACOUNT FROM MAT_ZC_M T,YDM_ZC_BUTTRESS S WHERE T.MAT_NO = S.MAT_NO
                 AND T.JUDGE_STOVE_NO = ?
                 AND T.BATCH_NO = ?
                 AND T.BATCH_GROUD_NO = ?
                 AND T.BELONG_CODE || '&' LIKE ('%' || ? || '%')
]]>
</query>
<query id = "FrmRunTimeRptZg.insertInOutHistory" desc = "转移入库出库历史表">
DECLARE
BEGIN
  FOR MYROW IN (SELECT SUM(T.ACT_COUNT) ACT_COUNT,
                       SUM(T.ACT_WEIGHT) ACT_WEIGHT,
                       SUM(T.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT,
                       SUM(T.ACT_LEN) ACT_LEN,
                       T.INSTOCK_DOC,
                       T.INSTOCK_TYPE_CODE,
                       T.INSTOCK_TYPE_NAME,
                       T.JUDGE_STOVE_NO,
                       T.BATCH_NO,
                       T.BATCH_GROUD_NO,
                       T.MATERIAL_NO,
                       T.MATERIAL_NAME,
                       T.PRODUCCODE,
                       T.PRODUCNAME,
                       T.STD_STYLE,
                       T.STD_STYLE_DESC,
                       T.STEELCODE,
                       T.STEELNAME,
                       T.SPEC_CODE,
                       T.SPEC_NAME,
                       T.MODEL_CODE,
                       T.MODEL_DESC,
                       T.STD_CODE,
                       T.STD_NAME,
                       T.GRADECODE,
                       T.GRADENAME,
                       T.PRO_ORDER_NO,
                       T.PLINE_CODE,
                       T.PLINE_NAME,
                       T.ACT_DIMATER,
                       T.ACT_HEIGHT,
                       T.ACT_LEN_MIN,
                       T.ACT_LEN_MAX,
                       T.BELONG_CODE,
                       T.BELONG_NAME,
                       T.STORAGE_NO,
                       T.MANAGEMENT_NO,
                       T.MANAGEMENT_NAME,
                       T.DEPARTMENT_CODE,
                       T.DEPARTMENT_DESC,
                       T.INSTOCK_TIME,
                       T.IN_TIME_F,
                       T.CREATE_NAME,
                       T.CREATE_TIME,
                       T.ORD_PK,
                       T.ORD_LN_PK,
                       T.ORD_LN_DLY_PK,
                       T.ORDER_NO,
                       T.ORDER_SEQ,
                       T.DELIVERY_NO,
                       T.PRODUCT_FLAG,
                       T.MAT_STATUS,
                       T.JUDGE_STD_NAME,
                       T.JUDGE_STD_CODE,
                       T.BAL_YEAR_MONTH,
                       T.SOURE_CODE,
                       T.SOURE_NAME,
                       T.MAT_ORIGIN_CODE,
                       T.MAT_ORIGIN_NAME,
                       T.ZG_STOVE_SQE,
                       T.QCM_STAUS
                  FROM YDM_ZC_INLIST T
                 WHERE T.BAL_YEAR_MONTH = ? 
                       #CONDITIONS#
                 GROUP BY T.INSTOCK_DOC,
                          T.INSTOCK_TYPE_CODE,
                          T.INSTOCK_TYPE_NAME,
                          T.JUDGE_STOVE_NO,
                          T.BATCH_NO,
                          T.BATCH_GROUD_NO,
                          T.MATERIAL_NO,
                          T.MATERIAL_NAME,
                          T.PRODUCCODE,
                          T.PRODUCNAME,
                          T.STD_STYLE,
                          T.STD_STYLE_DESC,
                          T.STEELCODE,
                          T.STEELNAME,
                          T.SPEC_CODE,
                          T.SPEC_NAME,
                          T.MODEL_CODE,
                          T.MODEL_DESC,
                          T.STD_CODE,
                          T.STD_NAME,
                          T.GRADECODE,
                          T.GRADENAME,
                          T.PRO_ORDER_NO,
                          T.PLINE_CODE,
                          T.PLINE_NAME,
                          T.ACT_DIMATER,
                          T.ACT_HEIGHT,
                          T.ACT_LEN_MIN,
                          T.ACT_LEN_MAX,
                          T.BELONG_CODE,
                          T.BELONG_NAME,
                          T.STORAGE_NO,
                          T.MANAGEMENT_NO,
                          T.MANAGEMENT_NAME,
                          T.DEPARTMENT_CODE,
                          T.DEPARTMENT_DESC,
                          T.INSTOCK_TIME,
                          T.IN_TIME_F,
                          T.CREATE_NAME,
                          T.CREATE_TIME,
                          T.ORD_PK,
                          T.ORD_LN_PK,
                          T.ORD_LN_DLY_PK,
                          T.ORDER_NO,
                          T.ORDER_SEQ,
                          T.DELIVERY_NO,
                          T.PRODUCT_FLAG,
                          T.MAT_STATUS,
                          T.JUDGE_STD_NAME,
                          T.JUDGE_STD_CODE,
                          T.BAL_YEAR_MONTH,
                          T.SOURE_CODE,
                          T.SOURE_NAME,
                          T.MAT_ORIGIN_CODE,
                          T.MAT_ORIGIN_NAME,
                          T.ZG_STOVE_SQE,
                          T.QCM_STAUS) LOOP
    INSERT INTO YDM_ZC_INLIST_HISTORY
      (ACT_COUNT,
       ACT_WEIGHT,
       ACT_THEORY_WEIGHT,
       ACT_LEN,
       INSTOCK_DOC,
       INSTOCK_TYPE_CODE,
       INSTOCK_TYPE_NAME,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       MATERIAL_NO,
       MATERIAL_NAME,
       PRODUCCODE,
       PRODUCNAME,
       STD_STYLE,
       STD_STYLE_DESC,
       STEELCODE,
       STEELNAME,
       SPEC_CODE,
       SPEC_NAME,
       MODEL_CODE,
       MODEL_DESC,
       STD_CODE,
       STD_NAME,
       GRADECODE,
       GRADENAME,
       PRO_ORDER_NO,
       PLINE_CODE,
       PLINE_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN_MIN,
       ACT_LEN_MAX,
       BELONG_CODE,
       BELONG_NAME,
       STORAGE_NO,
       MANAGEMENT_NO,
       MANAGEMENT_NAME,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       INSTOCK_TIME,
       IN_TIME_F,
       CREATE_NAME,
       CREATE_TIME,
       ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       ORDER_NO,
       ORDER_SEQ,
       DELIVERY_NO,
       PRODUCT_FLAG,
       MAT_STATUS,
       JUDGE_STD_NAME,
       JUDGE_STD_CODE,
       BAL_YEAR_MONTH,
       SOURE_CODE,
       SOURE_NAME,
       MAT_ORIGIN_CODE,
       MAT_ORIGIN_NAME,
       ZG_STOVE_SQE,
       QCM_STAUS)
    VALUES
      (MYROW.ACT_COUNT,
       MYROW.ACT_WEIGHT,
       MYROW.ACT_THEORY_WEIGHT,
       MYROW.ACT_LEN,
       MYROW.INSTOCK_DOC,
       MYROW.INSTOCK_TYPE_CODE,
       MYROW.INSTOCK_TYPE_NAME,
       MYROW.JUDGE_STOVE_NO,
       MYROW.BATCH_NO,
       MYROW.BATCH_GROUD_NO,
       MYROW.MATERIAL_NO,
       MYROW.MATERIAL_NAME,
       MYROW.PRODUCCODE,
       MYROW.PRODUCNAME,
       MYROW.STD_STYLE,
       MYROW.STD_STYLE_DESC,
       MYROW.STEELCODE,
       MYROW.STEELNAME,
       MYROW.SPEC_CODE,
       MYROW.SPEC_NAME,
       MYROW.MODEL_CODE,
       MYROW.MODEL_DESC,
       MYROW.STD_CODE,
       MYROW.STD_NAME,
       MYROW.GRADECODE,
       MYROW.GRADENAME,
       MYROW.PRO_ORDER_NO,
       MYROW.PLINE_CODE,
       MYROW.PLINE_NAME,
       MYROW.ACT_DIMATER,
       MYROW.ACT_HEIGHT,
       MYROW.ACT_LEN_MIN,
       MYROW.ACT_LEN_MAX,
       MYROW.BELONG_CODE,
       MYROW.BELONG_NAME,
       MYROW.STORAGE_NO,
       MYROW.MANAGEMENT_NO,
       MYROW.MANAGEMENT_NAME,
       MYROW.DEPARTMENT_CODE,
       MYROW.DEPARTMENT_DESC,
       MYROW.INSTOCK_TIME,
       MYROW.IN_TIME_F,
       MYROW.CREATE_NAME,
       MYROW.CREATE_TIME,
       MYROW.ORD_PK,
       MYROW.ORD_LN_PK,
       MYROW.ORD_LN_DLY_PK,
       MYROW.ORDER_NO,
       MYROW.ORDER_SEQ,
       MYROW.DELIVERY_NO,
       MYROW.PRODUCT_FLAG,
       MYROW.MAT_STATUS,
       MYROW.JUDGE_STD_NAME,
       MYROW.JUDGE_STD_CODE,
       MYROW.BAL_YEAR_MONTH,
       MYROW.SOURE_CODE,
       MYROW.SOURE_NAME,
       MYROW.MAT_ORIGIN_CODE,
       MYROW.MAT_ORIGIN_NAME,
       MYROW.ZG_STOVE_SQE,
       MYROW.QCM_STAUS);
    DELETE YDM_ZC_INLIST T
     WHERE T.INSTOCK_DOC = MYROW.INSTOCK_DOC
       AND T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
       AND T.BATCH_NO = MYROW.BATCH_NO
       AND T.BATCH_GROUD_NO = MYROW.BATCH_GROUD_NO
       AND T.BAL_YEAR_MONTH = MYROW.BAL_YEAR_MONTH;
    DELETE YDM_ZC_INLIST_XS T
     WHERE T.INSTOCK_DOC = MYROW.INSTOCK_DOC
       AND T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
       AND T.BATCH_NO = MYROW.BATCH_NO
       AND T.BATCH_GROUD_NO = MYROW.BATCH_GROUD_NO
       AND T.BAL_YEAR_MONTH = MYROW.BAL_YEAR_MONTH;
  END LOOP;
  FOR MYROW1 IN (SELECT SUM(T.ACT_COUNT) ACT_COUNT,
                        SUM(T.ACT_WEIGHT) ACT_WEIGHT,
                        SUM(T.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT,
                        SUM(T.ACT_LEN) ACT_LEN,
                        T.OUTSTOCK_PLAN_NO,
                        T.OUTSTOCK_DOC,
                        T.OUTSTOCK_TYPE_CODE,
                        T.OUTSTOCK_TYPE_NAME,
                        T.ICCAR_NO,
                        T.VEHICLE_NO,
                        T.LOT_NO,
                        T.JUDGE_STOVE_NO,
                        T.BATCH_NO,
                        T.BATCH_GROUD_NO,
                        T.MATERIAL_NO,
                        T.MATERIAL_NAME,
                        T.PRODUCCODE,
                        T.PRODUCNAME,
                        T.STD_STYLE,
                        T.STD_STYLE_DESC,
                        T.STEELCODE,
                        T.STEELNAME,
                        T.SPEC_CODE,
                        T.SPEC_NAME,
                        T.MODEL_CODE,
                        T.MODEL_DESC,
                        T.STD_CODE,
                        T.STD_NAME,
                        T.GRADECODE,
                        T.GRADENAME,
                        T.ACT_DIMATER,
                        T.ACT_HEIGHT,
                        T.ACT_LEN_MIN,
                        T.ACT_LEN_MAX,
                        T.PRO_ORDER_NO,
                        T.PLINE_CODE,
                        T.PLINE_NAME,
                        T.BELONG_CODE,
                        T.BELONG_NAME,
                        T.STORAGE_NO,
                        T.LOCATION_NO,
                        T.MANAGEMENT_NO,
                        T.MANAGEMENT_NAME,
                        T.TAR_STORAGE_NO,
                        T.TAR_LOCATION_NO,
                        T.TAR_MANAGEMENT_NO,
                        T.TAR_MANAGEMENT_NAME,
                        T.ORD_PK,
                        T.ORD_LN_PK,
                        T.ORD_LN_DLY_PK,
                        T.ORDER_NO,
                        T.ORDER_SEQ,
                        T.DELIVERY_NO,
                        T.PRODUCT_FLAG,
                        T.MAT_STATUS,
                        T.JUDGE_STD_NAME,
                        T.JUDGE_STD_CODE,
                        T.BAL_YEAR_MONTH
                   FROM YDM_ZC_OUTLIST T
                  WHERE T.BAL_YEAR_MONTH = ?
                  #CONDITIONS#
                  GROUP BY T.OUTSTOCK_PLAN_NO,
                           T.OUTSTOCK_DOC,
                           T.OUTSTOCK_TYPE_CODE,
                           T.OUTSTOCK_TYPE_NAME,
                           T.ICCAR_NO,
                           T.VEHICLE_NO,
                           T.LOT_NO,
                           T.JUDGE_STOVE_NO,
                           T.BATCH_NO,
                           T.BATCH_GROUD_NO,
                           T.MATERIAL_NO,
                           T.MATERIAL_NAME,
                           T.PRODUCCODE,
                           T.PRODUCNAME,
                           T.STD_STYLE,
                           T.STD_STYLE_DESC,
                           T.STEELCODE,
                           T.STEELNAME,
                           T.SPEC_CODE,
                           T.SPEC_NAME,
                           T.MODEL_CODE,
                           T.MODEL_DESC,
                           T.STD_CODE,
                           T.STD_NAME,
                           T.GRADECODE,
                           T.GRADENAME,
                           T.ACT_DIMATER,
                           T.ACT_HEIGHT,
                           T.ACT_LEN_MIN,
                           T.ACT_LEN_MAX,
                           T.PRO_ORDER_NO,
                           T.PLINE_CODE,
                           T.PLINE_NAME,
                           T.BELONG_CODE,
                           T.BELONG_NAME,
                           T.STORAGE_NO,
                           T.LOCATION_NO,
                           T.MANAGEMENT_NO,
                           T.MANAGEMENT_NAME,
                           T.TAR_STORAGE_NO,
                           T.TAR_LOCATION_NO,
                           T.TAR_MANAGEMENT_NO,
                           T.TAR_MANAGEMENT_NAME,
                           T.ORD_PK,
                           T.ORD_LN_PK,
                           T.ORD_LN_DLY_PK,
                           T.ORDER_NO,
                           T.ORDER_SEQ,
                           T.DELIVERY_NO,
                           T.PRODUCT_FLAG,
                           T.MAT_STATUS,
                           T.JUDGE_STD_NAME,
                           T.JUDGE_STD_CODE,
                           T.BAL_YEAR_MONTH) LOOP
    INSERT INTO YDM_ZC_OUTLIST_HISTORY
      (ACT_COUNT,
       ACT_WEIGHT,
       ACT_THEORY_WEIGHT,
       ACT_LEN,
       OUTSTOCK_PLAN_NO,
       OUTSTOCK_DOC,
       OUTSTOCK_TYPE_CODE,
       OUTSTOCK_TYPE_NAME,
       ICCAR_NO,
       VEHICLE_NO,
       LOT_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       MATERIAL_NO,
       MATERIAL_NAME,
       PRODUCCODE,
       PRODUCNAME,
       STD_STYLE,
       STD_STYLE_DESC,
       STEELCODE,
       STEELNAME,
       SPEC_CODE,
       SPEC_NAME,
       MODEL_CODE,
       MODEL_DESC,
       STD_CODE,
       STD_NAME,
       GRADECODE,
       GRADENAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN_MIN,
       ACT_LEN_MAX,
       PRO_ORDER_NO,
       PLINE_CODE,
       PLINE_NAME,
       BELONG_CODE,
       BELONG_NAME,
       STORAGE_NO,
       LOCATION_NO,
       MANAGEMENT_NO,
       MANAGEMENT_NAME,
       TAR_STORAGE_NO,
       TAR_LOCATION_NO,
       TAR_MANAGEMENT_NO,
       TAR_MANAGEMENT_NAME,
       ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       ORDER_NO,
       ORDER_SEQ,
       DELIVERY_NO,
       PRODUCT_FLAG,
       MAT_STATUS,
       JUDGE_STD_NAME,
       JUDGE_STD_CODE,
       BAL_YEAR_MONTH)
    VALUES
      (MYROW1.ACT_COUNT,
       MYROW1.ACT_WEIGHT,
       MYROW1.ACT_THEORY_WEIGHT,
       MYROW1.ACT_LEN,
       MYROW1.OUTSTOCK_PLAN_NO,
       MYROW1.OUTSTOCK_DOC,
       MYROW1.OUTSTOCK_TYPE_CODE,
       MYROW1.OUTSTOCK_TYPE_NAME,
       MYROW1.ICCAR_NO,
       MYROW1.VEHICLE_NO,
       MYROW1.LOT_NO,
       MYROW1.JUDGE_STOVE_NO,
       MYROW1.BATCH_NO,
       MYROW1.BATCH_GROUD_NO,
       MYROW1.MATERIAL_NO,
       MYROW1.MATERIAL_NAME,
       MYROW1.PRODUCCODE,
       MYROW1.PRODUCNAME,
       MYROW1.STD_STYLE,
       MYROW1.STD_STYLE_DESC,
       MYROW1.STEELCODE,
       MYROW1.STEELNAME,
       MYROW1.SPEC_CODE,
       MYROW1.SPEC_NAME,
       MYROW1.MODEL_CODE,
       MYROW1.MODEL_DESC,
       MYROW1.STD_CODE,
       MYROW1.STD_NAME,
       MYROW1.GRADECODE,
       MYROW1.GRADENAME,
       MYROW1.ACT_DIMATER,
       MYROW1.ACT_HEIGHT,
       MYROW1.ACT_LEN_MIN,
       MYROW1.ACT_LEN_MAX,
       MYROW1.PRO_ORDER_NO,
       MYROW1.PLINE_CODE,
       MYROW1.PLINE_NAME,
       MYROW1.BELONG_CODE,
       MYROW1.BELONG_NAME,
       MYROW1.STORAGE_NO,
       MYROW1.LOCATION_NO,
       MYROW1.MANAGEMENT_NO,
       MYROW1.MANAGEMENT_NAME,
       MYROW1.TAR_STORAGE_NO,
       MYROW1.TAR_LOCATION_NO,
       MYROW1.TAR_MANAGEMENT_NO,
       MYROW1.TAR_MANAGEMENT_NAME,
       MYROW1.ORD_PK,
       MYROW1.ORD_LN_PK,
       MYROW1.ORD_LN_DLY_PK,
       MYROW1.ORDER_NO,
       MYROW1.ORDER_SEQ,
       MYROW1.DELIVERY_NO,
       MYROW1.PRODUCT_FLAG,
       MYROW1.MAT_STATUS,
       MYROW1.JUDGE_STD_NAME,
       MYROW1.JUDGE_STD_CODE,
       MYROW1.BAL_YEAR_MONTH);
      DELETE FROM YDM_ZC_OUTLIST T
       WHERE T.OUTSTOCK_DOC = MYROW1.OUTSTOCK_DOC
         AND T.OUTSTOCK_TYPE_CODE = MYROW1.OUTSTOCK_TYPE_CODE
         AND T.BAL_YEAR_MONTH = MYROW1.BAL_YEAR_MONTH; 
      DELETE FROM YDM_ZC_OUTLIST_XS T
       WHERE T.OUTSTOCK_DOC = MYROW1.OUTSTOCK_DOC
         AND T.OUTSTOCK_TYPE_CODE = MYROW1.OUTSTOCK_TYPE_CODE
         AND T.BAL_YEAR_MONTH = MYROW1.BAL_YEAR_MONTH; 
  END LOOP;
END;
</query>
<query id = "FrmRunTimeRptZg.insertInOutHistoryB" desc = "结转转移出入库历史记录">
<![CDATA[
DECLARE
BEGIN
  FOR MYROW IN (SELECT SUM(T.ACT_COUNT) ACT_COUNT,
                       SUM(T.ACT_WEIGHT) ACT_WEIGHT,
                       SUM(T.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT,
                       SUM(T.ACT_LEN) ACT_LEN,
                       T.INSTOCK_DOC,
                       T.INSTOCK_TYPE_CODE,
                       T.INSTOCK_TYPE_NAME,
                       T.JUDGE_STOVE_NO,
                       T.BATCH_NO,
                       T.BATCH_GROUD_NO,
                       T.MATERIAL_NO,
                       T.MATERIAL_NAME,
                       T.PRODUCCODE,
                       T.PRODUCNAME,
                       T.STD_STYLE,
                       T.STD_STYLE_DESC,
                       T.STEELCODE,
                       T.STEELNAME,
                       T.SPEC_CODE,
                       T.SPEC_NAME,
                       T.MODEL_CODE,
                       T.MODEL_DESC,
                       T.STD_CODE,
                       T.STD_NAME,
                       T.GRADECODE,
                       T.GRADENAME,
                       T.PRO_ORDER_NO,
                       T.PLINE_CODE,
                       T.PLINE_NAME,
                       T.ACT_DIMATER,
                       T.ACT_HEIGHT,
                       T.ACT_LEN_MIN,
                       T.ACT_LEN_MAX,
                       T.BELONG_CODE,
                       T.BELONG_NAME,
                       T.STORAGE_NO,
                       T.MANAGEMENT_NO,
                       T.MANAGEMENT_NAME,
                       T.DEPARTMENT_CODE,
                       T.DEPARTMENT_DESC,
                       T.INSTOCK_TIME,
                       T.IN_TIME_F,
                       T.CREATE_NAME,
                       T.CREATE_TIME,
                       T.ORD_PK,
                       T.ORD_LN_PK,
                       T.ORD_LN_DLY_PK,
                       T.ORDER_NO,
                       T.ORDER_SEQ,
                       T.DELIVERY_NO,
                       T.PRODUCT_FLAG,
                       T.MAT_STATUS,
                       T.JUDGE_STD_NAME,
                       T.JUDGE_STD_CODE,
                       T.BAL_YEAR_MONTH,
                       T.SOURE_CODE,
                       T.SOURE_NAME,
                       T.MAT_ORIGIN_CODE,
                       T.MAT_ORIGIN_NAME,
                       T.ZG_STOVE_SQE,
                       T.QCM_STAUS
                  FROM YDM_ZC_INLIST T
                 WHERE T.BAL_YEAR_MONTH = '#BAL_YEAR_MONTH#' 
                      AND T.BELONG_CODE || '&' LIKE ('%' ||'#BELONG_CODE#'|| '%')
                      AND T.INSTOCK_TYPE_CODE IN('800701','800702','800704','800706','800707')
                 GROUP BY T.INSTOCK_DOC,
                          T.INSTOCK_TYPE_CODE,
                          T.INSTOCK_TYPE_NAME,
                          T.JUDGE_STOVE_NO,
                          T.BATCH_NO,
                          T.BATCH_GROUD_NO,
                          T.MATERIAL_NO,
                          T.MATERIAL_NAME,
                          T.PRODUCCODE,
                          T.PRODUCNAME,
                          T.STD_STYLE,
                          T.STD_STYLE_DESC,
                          T.STEELCODE,
                          T.STEELNAME,
                          T.SPEC_CODE,
                          T.SPEC_NAME,
                          T.MODEL_CODE,
                          T.MODEL_DESC,
                          T.STD_CODE,
                          T.STD_NAME,
                          T.GRADECODE,
                          T.GRADENAME,
                          T.PRO_ORDER_NO,
                          T.PLINE_CODE,
                          T.PLINE_NAME,
                          T.ACT_DIMATER,
                          T.ACT_HEIGHT,
                          T.ACT_LEN_MIN,
                          T.ACT_LEN_MAX,
                          T.BELONG_CODE,
                          T.BELONG_NAME,
                          T.STORAGE_NO,
                          T.MANAGEMENT_NO,
                          T.MANAGEMENT_NAME,
                          T.DEPARTMENT_CODE,
                          T.DEPARTMENT_DESC,
                          T.INSTOCK_TIME,
                          T.IN_TIME_F,
                          T.CREATE_NAME,
                          T.CREATE_TIME,
                          T.ORD_PK,
                          T.ORD_LN_PK,
                          T.ORD_LN_DLY_PK,
                          T.ORDER_NO,
                          T.ORDER_SEQ,
                          T.DELIVERY_NO,
                          T.PRODUCT_FLAG,
                          T.MAT_STATUS,
                          T.JUDGE_STD_NAME,
                          T.JUDGE_STD_CODE,
                          T.BAL_YEAR_MONTH,
                          T.SOURE_CODE,
                          T.SOURE_NAME,
                          T.MAT_ORIGIN_CODE,
                          T.MAT_ORIGIN_NAME,
                          T.ZG_STOVE_SQE,
                          T.QCM_STAUS) LOOP
    INSERT INTO YDM_ZC_INLIST_HISTORY
      (ACT_COUNT,
       ACT_WEIGHT,
       ACT_THEORY_WEIGHT,
       ACT_LEN,
       INSTOCK_DOC,
       INSTOCK_TYPE_CODE,
       INSTOCK_TYPE_NAME,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       MATERIAL_NO,
       MATERIAL_NAME,
       PRODUCCODE,
       PRODUCNAME,
       STD_STYLE,
       STD_STYLE_DESC,
       STEELCODE,
       STEELNAME,
       SPEC_CODE,
       SPEC_NAME,
       MODEL_CODE,
       MODEL_DESC,
       STD_CODE,
       STD_NAME,
       GRADECODE,
       GRADENAME,
       PRO_ORDER_NO,
       PLINE_CODE,
       PLINE_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN_MIN,
       ACT_LEN_MAX,
       BELONG_CODE,
       BELONG_NAME,
       STORAGE_NO,
       MANAGEMENT_NO,
       MANAGEMENT_NAME,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       INSTOCK_TIME,
       IN_TIME_F,
       CREATE_NAME,
       CREATE_TIME,
       ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       ORDER_NO,
       ORDER_SEQ,
       DELIVERY_NO,
       PRODUCT_FLAG,
       MAT_STATUS,
       JUDGE_STD_NAME,
       JUDGE_STD_CODE,
       BAL_YEAR_MONTH,
       SOURE_CODE,
       SOURE_NAME,
       MAT_ORIGIN_CODE,
       MAT_ORIGIN_NAME,
       ZG_STOVE_SQE,
       QCM_STAUS)
    VALUES
      (MYROW.ACT_COUNT,
       MYROW.ACT_WEIGHT,
       MYROW.ACT_THEORY_WEIGHT,
       MYROW.ACT_LEN,
       MYROW.INSTOCK_DOC,
       MYROW.INSTOCK_TYPE_CODE,
       MYROW.INSTOCK_TYPE_NAME,
       MYROW.JUDGE_STOVE_NO,
       MYROW.BATCH_NO,
       MYROW.BATCH_GROUD_NO,
       MYROW.MATERIAL_NO,
       MYROW.MATERIAL_NAME,
       MYROW.PRODUCCODE,
       MYROW.PRODUCNAME,
       MYROW.STD_STYLE,
       MYROW.STD_STYLE_DESC,
       MYROW.STEELCODE,
       MYROW.STEELNAME,
       MYROW.SPEC_CODE,
       MYROW.SPEC_NAME,
       MYROW.MODEL_CODE,
       MYROW.MODEL_DESC,
       MYROW.STD_CODE,
       MYROW.STD_NAME,
       MYROW.GRADECODE,
       MYROW.GRADENAME,
       MYROW.PRO_ORDER_NO,
       MYROW.PLINE_CODE,
       MYROW.PLINE_NAME,
       MYROW.ACT_DIMATER,
       MYROW.ACT_HEIGHT,
       MYROW.ACT_LEN_MIN,
       MYROW.ACT_LEN_MAX,
       MYROW.BELONG_CODE,
       MYROW.BELONG_NAME,
       MYROW.STORAGE_NO,
       MYROW.MANAGEMENT_NO,
       MYROW.MANAGEMENT_NAME,
       MYROW.DEPARTMENT_CODE,
       MYROW.DEPARTMENT_DESC,
       MYROW.INSTOCK_TIME,
       MYROW.IN_TIME_F,
       MYROW.CREATE_NAME,
       MYROW.CREATE_TIME,
       MYROW.ORD_PK,
       MYROW.ORD_LN_PK,
       MYROW.ORD_LN_DLY_PK,
       MYROW.ORDER_NO,
       MYROW.ORDER_SEQ,
       MYROW.DELIVERY_NO,
       MYROW.PRODUCT_FLAG,
       MYROW.MAT_STATUS,
       MYROW.JUDGE_STD_NAME,
       MYROW.JUDGE_STD_CODE,
       MYROW.BAL_YEAR_MONTH,
       MYROW.SOURE_CODE,
       MYROW.SOURE_NAME,
       MYROW.MAT_ORIGIN_CODE,
       MYROW.MAT_ORIGIN_NAME,
       MYROW.ZG_STOVE_SQE,
       MYROW.QCM_STAUS);
    DELETE YDM_ZC_INLIST T
     WHERE T.INSTOCK_DOC = MYROW.INSTOCK_DOC
       AND T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
       AND T.BATCH_NO = MYROW.BATCH_NO
       AND T.BATCH_GROUD_NO = MYROW.BATCH_GROUD_NO
       AND T.BAL_YEAR_MONTH = MYROW.BAL_YEAR_MONTH;
    DELETE YDM_ZC_INLIST_XS T
     WHERE T.INSTOCK_DOC = MYROW.INSTOCK_DOC
       AND T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
       AND T.BATCH_NO = MYROW.BATCH_NO
       AND T.BATCH_GROUD_NO = MYROW.BATCH_GROUD_NO
       AND T.BAL_YEAR_MONTH = MYROW.BAL_YEAR_MONTH;
  END LOOP;
  FOR MYROW1 IN (SELECT SUM(T.ACT_COUNT) ACT_COUNT,
                        SUM(T.ACT_WEIGHT) ACT_WEIGHT,
                        SUM(T.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT,
                        SUM(T.ACT_LEN) ACT_LEN,
                        T.OUTSTOCK_PLAN_NO,
                        T.OUTSTOCK_DOC,
                        T.OUTSTOCK_TYPE_CODE,
                        T.OUTSTOCK_TYPE_NAME,
                        T.ICCAR_NO,
                        T.VEHICLE_NO,
                        T.LOT_NO,
                        T.JUDGE_STOVE_NO,
                        T.BATCH_NO,
                        T.BATCH_GROUD_NO,
                        T.MATERIAL_NO,
                        T.MATERIAL_NAME,
                        T.PRODUCCODE,
                        T.PRODUCNAME,
                        T.STD_STYLE,
                        T.STD_STYLE_DESC,
                        T.STEELCODE,
                        T.STEELNAME,
                        T.SPEC_CODE,
                        T.SPEC_NAME,
                        T.MODEL_CODE,
                        T.MODEL_DESC,
                        T.STD_CODE,
                        T.STD_NAME,
                        T.GRADECODE,
                        T.GRADENAME,
                        T.ACT_DIMATER,
                        T.ACT_HEIGHT,
                        T.ACT_LEN_MIN,
                        T.ACT_LEN_MAX,
                        T.PRO_ORDER_NO,
                        T.PLINE_CODE,
                        T.PLINE_NAME,
                        T.BELONG_CODE,
                        T.BELONG_NAME,
                        T.STORAGE_NO,
                        T.LOCATION_NO,
                        T.MANAGEMENT_NO,
                        T.MANAGEMENT_NAME,
                        T.TAR_STORAGE_NO,
                        T.TAR_LOCATION_NO,
                        T.TAR_MANAGEMENT_NO,
                        T.TAR_MANAGEMENT_NAME,
                        T.ORD_PK,
                        T.ORD_LN_PK,
                        T.ORD_LN_DLY_PK,
                        T.ORDER_NO,
                        T.ORDER_SEQ,
                        T.DELIVERY_NO,
                        T.PRODUCT_FLAG,
                        T.MAT_STATUS,
                        T.JUDGE_STD_NAME,
                        T.JUDGE_STD_CODE,
                        T.BAL_YEAR_MONTH
                   FROM YDM_ZC_OUTLIST T
                  WHERE T.BAL_YEAR_MONTH = '#BAL_YEAR_MONTH#'
                        AND T.BELONG_CODE || '&' LIKE ('%' ||'#BELONG_CODE#'|| '%')
                        AND T.OUTSTOCK_TYPE_CODE IN('800801','800806','800809')
                  GROUP BY T.OUTSTOCK_PLAN_NO,
                           T.OUTSTOCK_DOC,
                           T.OUTSTOCK_TYPE_CODE,
                           T.OUTSTOCK_TYPE_NAME,
                           T.ICCAR_NO,
                           T.VEHICLE_NO,
                           T.LOT_NO,
                           T.JUDGE_STOVE_NO,
                           T.BATCH_NO,
                           T.BATCH_GROUD_NO,
                           T.MATERIAL_NO,
                           T.MATERIAL_NAME,
                           T.PRODUCCODE,
                           T.PRODUCNAME,
                           T.STD_STYLE,
                           T.STD_STYLE_DESC,
                           T.STEELCODE,
                           T.STEELNAME,
                           T.SPEC_CODE,
                           T.SPEC_NAME,
                           T.MODEL_CODE,
                           T.MODEL_DESC,
                           T.STD_CODE,
                           T.STD_NAME,
                           T.GRADECODE,
                           T.GRADENAME,
                           T.ACT_DIMATER,
                           T.ACT_HEIGHT,
                           T.ACT_LEN_MIN,
                           T.ACT_LEN_MAX,
                           T.PRO_ORDER_NO,
                           T.PLINE_CODE,
                           T.PLINE_NAME,
                           T.BELONG_CODE,
                           T.BELONG_NAME,
                           T.STORAGE_NO,
                           T.LOCATION_NO,
                           T.MANAGEMENT_NO,
                           T.MANAGEMENT_NAME,
                           T.TAR_STORAGE_NO,
                           T.TAR_LOCATION_NO,
                           T.TAR_MANAGEMENT_NO,
                           T.TAR_MANAGEMENT_NAME,
                           T.ORD_PK,
                           T.ORD_LN_PK,
                           T.ORD_LN_DLY_PK,
                           T.ORDER_NO,
                           T.ORDER_SEQ,
                           T.DELIVERY_NO,
                           T.PRODUCT_FLAG,
                           T.MAT_STATUS,
                           T.JUDGE_STD_NAME,
                           T.JUDGE_STD_CODE,
                           T.BAL_YEAR_MONTH) LOOP
    INSERT INTO YDM_ZC_OUTLIST_HISTORY
      (ACT_COUNT,
       ACT_WEIGHT,
       ACT_THEORY_WEIGHT,
       ACT_LEN,
       OUTSTOCK_PLAN_NO,
       OUTSTOCK_DOC,
       OUTSTOCK_TYPE_CODE,
       OUTSTOCK_TYPE_NAME,
       ICCAR_NO,
       VEHICLE_NO,
       LOT_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       MATERIAL_NO,
       MATERIAL_NAME,
       PRODUCCODE,
       PRODUCNAME,
       STD_STYLE,
       STD_STYLE_DESC,
       STEELCODE,
       STEELNAME,
       SPEC_CODE,
       SPEC_NAME,
       MODEL_CODE,
       MODEL_DESC,
       STD_CODE,
       STD_NAME,
       GRADECODE,
       GRADENAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN_MIN,
       ACT_LEN_MAX,
       PRO_ORDER_NO,
       PLINE_CODE,
       PLINE_NAME,
       BELONG_CODE,
       BELONG_NAME,
       STORAGE_NO,
       LOCATION_NO,
       MANAGEMENT_NO,
       MANAGEMENT_NAME,
       TAR_STORAGE_NO,
       TAR_LOCATION_NO,
       TAR_MANAGEMENT_NO,
       TAR_MANAGEMENT_NAME,
       ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       ORDER_NO,
       ORDER_SEQ,
       DELIVERY_NO,
       PRODUCT_FLAG,
       MAT_STATUS,
       JUDGE_STD_NAME,
       JUDGE_STD_CODE,
       BAL_YEAR_MONTH)
    VALUES
      (MYROW1.ACT_COUNT,
       MYROW1.ACT_WEIGHT,
       MYROW1.ACT_THEORY_WEIGHT,
       MYROW1.ACT_LEN,
       MYROW1.OUTSTOCK_PLAN_NO,
       MYROW1.OUTSTOCK_DOC,
       MYROW1.OUTSTOCK_TYPE_CODE,
       MYROW1.OUTSTOCK_TYPE_NAME,
       MYROW1.ICCAR_NO,
       MYROW1.VEHICLE_NO,
       MYROW1.LOT_NO,
       MYROW1.JUDGE_STOVE_NO,
       MYROW1.BATCH_NO,
       MYROW1.BATCH_GROUD_NO,
       MYROW1.MATERIAL_NO,
       MYROW1.MATERIAL_NAME,
       MYROW1.PRODUCCODE,
       MYROW1.PRODUCNAME,
       MYROW1.STD_STYLE,
       MYROW1.STD_STYLE_DESC,
       MYROW1.STEELCODE,
       MYROW1.STEELNAME,
       MYROW1.SPEC_CODE,
       MYROW1.SPEC_NAME,
       MYROW1.MODEL_CODE,
       MYROW1.MODEL_DESC,
       MYROW1.STD_CODE,
       MYROW1.STD_NAME,
       MYROW1.GRADECODE,
       MYROW1.GRADENAME,
       MYROW1.ACT_DIMATER,
       MYROW1.ACT_HEIGHT,
       MYROW1.ACT_LEN_MIN,
       MYROW1.ACT_LEN_MAX,
       MYROW1.PRO_ORDER_NO,
       MYROW1.PLINE_CODE,
       MYROW1.PLINE_NAME,
       MYROW1.BELONG_CODE,
       MYROW1.BELONG_NAME,
       MYROW1.STORAGE_NO,
       MYROW1.LOCATION_NO,
       MYROW1.MANAGEMENT_NO,
       MYROW1.MANAGEMENT_NAME,
       MYROW1.TAR_STORAGE_NO,
       MYROW1.TAR_LOCATION_NO,
       MYROW1.TAR_MANAGEMENT_NO,
       MYROW1.TAR_MANAGEMENT_NAME,
       MYROW1.ORD_PK,
       MYROW1.ORD_LN_PK,
       MYROW1.ORD_LN_DLY_PK,
       MYROW1.ORDER_NO,
       MYROW1.ORDER_SEQ,
       MYROW1.DELIVERY_NO,
       MYROW1.PRODUCT_FLAG,
       MYROW1.MAT_STATUS,
       MYROW1.JUDGE_STD_NAME,
       MYROW1.JUDGE_STD_CODE,
       MYROW1.BAL_YEAR_MONTH);
      DELETE FROM YDM_ZC_OUTLIST T
       WHERE T.OUTSTOCK_DOC = MYROW1.OUTSTOCK_DOC
         AND T.OUTSTOCK_TYPE_CODE = MYROW1.OUTSTOCK_TYPE_CODE
         AND T.BAL_YEAR_MONTH = MYROW1.BAL_YEAR_MONTH; 
      DELETE FROM YDM_ZC_OUTLIST_XS T
       WHERE T.OUTSTOCK_DOC = MYROW1.OUTSTOCK_DOC
         AND T.OUTSTOCK_TYPE_CODE = MYROW1.OUTSTOCK_TYPE_CODE
         AND T.BAL_YEAR_MONTH = MYROW1.BAL_YEAR_MONTH;    
  END LOOP;
END;
]]>
</query>
</queryMap>