<?xml version="1.0" encoding="UTF-8"?>
 
<queryMap desc="包装要求">
   <query id="PackAndMSC.GetMSC" desc="获取冶金规范码">
		<![CDATA[ 
		      SELECT T.MSC,T.MSC_DESC
		      FROM COM_MSC T
		      WHERE T.VALIDFLAG!='D'   
		]]>
	</query>
	<query id="PackAndMSC.XZSpec" desc="获取限制规格">
		<![CDATA[ 
		     SELECT T.BASENAME,T.BASECODE
             FROM COM_BASE_INFO T
             WHERE T.SORTCODE='4003' AND T.VALIDFLAG='1'
		]]>
	</query>
	<query id="PackAndMSC.Base" desc="获取包装项大类">
		<![CDATA[ 
		     SELECT T.BASENAME,T.BASECODE
             FROM COM_BASE_INFO T
             WHERE T.SORTCODE='4004' AND T.VALIDFLAG='1'
		]]>
	</query>
	<query id="PackAndMSC.Item" desc="获取包装项目">
		<![CDATA[ 
		     SELECT T.BASENAME,T.BASECODE
             FROM COM_BASE_INFO T
             WHERE T.SORTCODE='4005' AND T.VALIDFLAG='1'
		]]>
	</query>
	<query id="PackAndMSC.Note" desc="获取包装要求">
		<![CDATA[ 
		     SELECT T.BASENAME,T.BASECODE
             FROM COM_BASE_INFO T
             WHERE T.SORTCODE='4006' AND T.VALIDFLAG='1'
		]]>
	</query>
	<query id="PackAndMSC.JGSpec" desc="获取接箍规格">
		<![CDATA[ 
		     SELECT T.SPEC_NAME,T.SPEC_CODE 
		     FROM COM_BASE_SPEC T
		     WHERE T.MSC_STYLE='C' AND T.VALIDFLAG='1'
		]]>
	</query>
	<query id="PackAndMSC.model" desc="获取扣型集合">
		<![CDATA[ 
		      SELECT 'FALSE' CHK, T.MODEL_CODE,T.MODEL_DESC
		      FROM COM_BASE_MODEL T
		      WHERE T.VALIDFLAG='1'   
		]]>
	</query>
	<query id="PackAndMSC.maxid" desc="获取主表最大序号">
		<![CDATA[ 
		    SELECT T.INDEX_SEQ
            FROM 
            (SELECT INDEX_SEQ FROM COM_MSC_STD_PACK WHERE MSC=? ORDER BY INDEX_SEQ DESC ) T
            WHERE ROWNUM='1'  
		]]>
	</query>
	<query id="PackAndMSC.childmaxid" desc="获取从表最大序号">
		<![CDATA[ 
		    SELECT T.INDEX_SEQ_C
            FROM 
            ( SELECT INDEX_SEQ_C 
              FROM COM_MSC_STD_PACK_C 
              WHERE MSC=? AND INDEX_SEQ=? ORDER BY INDEX_SEQ_C DESC ) T
            WHERE ROWNUM='1'
		]]>
	</query>
	<query id="PackAndMSC.QUERY_P" desc="主表查询">
		<![CDATA[
       SELECT 
       'FALSE' CHK,
       MSC,
       INDEX_SEQ,
       MODEL_CODE,
       MODEL_DESC,
       SIZE_CODE2,
       SIZE_NAME2,
       SIZE_MIN_SIGN2,
       SIZE_MIN2,
       SIZE_MAX_SIGN2,
       SIZE_MAX2,
       SIZE_CODE,
       SIZE_NAME,
       SIZE_MIN_SIGN,
       SIZE_MIN,
       SIZE_MAX_SIGN,
       SIZE_MAX,
       SIZE_JG_CODE,
       SIZE_JG_NAME,
       CREATE_NAME,
       TO_CHAR(CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       UPDATE_NAME,
       TO_CHAR(UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME,'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       DECODE(VALIDFLAG,'1','有效','0','无效') VALIDFLAG,
       MEMO
       FROM COM_MSC_STD_PACK  WHERE   VALIDFLAG IN('1', ?) 
       AND MSC=?
		]]>
	</query> 
	
	<query id="PackAndMSC.QUERY_C" desc="从表查询">
		<![CDATA[
        SELECT 
        'FALSE' CHK,
        MSC,
        INDEX_SEQ,
        INDEX_SEQ_C,
        BASE_CODE,
        BASE_DESC,
        ITEM_CODE,
        ITEM_DESC,
        NOTE_CODE,
        NOTE_DESC,
        CREATE_NAME,
        TO_CHAR(CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
        UPDATE_NAME,
        TO_CHAR(UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
        DELETE_NAME,
        TO_CHAR(DELETE_TIME,'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
        DECODE(VALIDFLAG,'1','有效','0','无效') VALIDFLAG,
        MEMO
        FROM COM_MSC_STD_PACK_C WHERE VALIDFLAG IN('1', ?) 
        AND MSC=?
		]]>
	</query> 
	
	<query id="PackAndMSC.DELETE_P" desc="删除主表">
		<![CDATA[ 
		        UPDATE COM_MSC_STD_PACK
                SET VALIDFLAG='0',
                DELETE_NAME=?,
                DELETE_TIME=SYSDATE
                WHERE MSC = ?  AND INDEX_SEQ = ?
                AND VALIDFLAG='1'
		]]>
	</query>
	
	<query id="PackAndMSC.DELETE_C1" desc="删除从表多条(冶金规范码和序号)">
		<![CDATA[ 
		        UPDATE COM_MSC_STD_PACK_C
                SET VALIDFLAG='0',
                DELETE_NAME=?,
                DELETE_TIME=SYSDATE
                WHERE MSC = ?  AND INDEX_SEQ = ?   
                AND VALIDFLAG='1'
		]]>
	</query>
	
	<query id="PackAndMSC.DELETE_C2" desc="删除从表一条(冶金规范码和序号和子表序号)">
		<![CDATA[ 
		        UPDATE COM_MSC_STD_PACK_C
                SET VALIDFLAG='0',
                DELETE_NAME=?,
                DELETE_TIME=SYSDATE
                WHERE MSC = ?  AND INDEX_SEQ = ?  AND INDEX_SEQ_C=? 
                AND VALIDFLAG='1'
		]]>
	</query>
	<query id="PackAndMSC.Resume_P" desc="恢复主表数据">
		<![CDATA[ 
		        UPDATE COM_MSC_STD_PACK
                SET VALIDFLAG='1',
                DELETE_NAME='',
                DELETE_TIME=''
                WHERE MSC = ?  AND INDEX_SEQ = ? AND VALIDFLAG='0'
		]]>
	</query>
	
	<query id="PackAndMSC.Resume_C" desc="恢复从表数据">
		<![CDATA[ 
		UPDATE COM_MSC_STD_PACK_C
        SET 
        DELETE_NAME = '',
        DELETE_TIME = '',
        VALIDFLAG   = '1' 
        WHERE MSC = ?
        AND INDEX_SEQ = ?
        AND INDEX_SEQ_C =?
        AND VALIDFLAG='0'
		]]>
	</query>
	
	<query id="PackAndMSC.ADD_P" desc="添加主表数据">
		<![CDATA[ 
	INSERT INTO COM_MSC_STD_PACK
    (MSC,
     INDEX_SEQ,
     MODEL_CODE,
     MODEL_DESC,
     SIZE_CODE2,
     SIZE_NAME2,
     SIZE_MIN_SIGN2,
     SIZE_MIN2,
     SIZE_MAX_SIGN2,
     SIZE_MAX2,
     SIZE_CODE,
     SIZE_NAME,
     SIZE_MIN_SIGN,
     SIZE_MIN,
     SIZE_MAX_SIGN,
     SIZE_MAX,
     SIZE_JG_CODE,
     SIZE_JG_NAME,
     CREATE_NAME,
     CREATE_TIME,
     MEMO)
     VALUES
    (?,?,?,?,?,?,?,?,?,?,
     ?,?,?,?,?,?,?,?,?,SYSDATE,?)
		]]>
	</query>
	
	<query id="PackAndMSC.ADD_C" desc="添加从表数据">
		<![CDATA[ 
	 INSERT INTO COM_MSC_STD_PACK_C
    (MSC,
     INDEX_SEQ,
     INDEX_SEQ_C,
     BASE_CODE,
     BASE_DESC,
     ITEM_CODE,
     ITEM_DESC,
     NOTE_CODE,
     NOTE_DESC,
     CREATE_NAME,
     CREATE_TIME,
     MEMO)
     VALUES  (?,?,?,?,?,?,?,?,?,?,SYSDATE,?) 
		]]>
	</query>
	
	<query id="PackAndMSC.UPDATE_P" desc="更新主表信息">
		<![CDATA[ 
	   UPDATE COM_MSC_STD_PACK
       SET MSC        = ?,   
       INDEX_SEQ      = ?,
       MODEL_CODE     = ?,
       MODEL_DESC     = ?,
       SIZE_CODE2     = ?,
       SIZE_NAME2     = ?,
       SIZE_MIN_SIGN2 = ?,
       SIZE_MIN2      = ?,
       SIZE_MAX_SIGN2 = ?,
       SIZE_MAX2      = ?,
       SIZE_CODE      = ?,
       SIZE_NAME      = ?,
       SIZE_MIN_SIGN  = ?,
       SIZE_MIN       = ?,
       SIZE_MAX_SIGN  = ?,
       SIZE_MAX       = ?,
       SIZE_JG_CODE   = ?,
       SIZE_JG_NAME   = ?,
       UPDATE_NAME    = ?,
       UPDATE_TIME    = SYSDATE,
       MEMO           = ?
       WHERE MSC = ?   AND INDEX_SEQ = ? AND VALIDFLAG='1'
		]]>
	</query>
	
	<query id="PackAndMSC.UPDATE_C" desc="更新从表信息">
		<![CDATA[ 
	  UPDATE COM_MSC_STD_PACK_C
      SET MSC       = ?,
        INDEX_SEQ   = ?,
        INDEX_SEQ_C = ?,
        BASE_CODE   = ?,
        BASE_DESC   = ?,
        ITEM_CODE   = ?,
        ITEM_DESC   = ?,
        NOTE_CODE   = ?,
        NOTE_DESC   = ?, 
        UPDATE_NAME = ?,
        UPDATE_TIME = SYSDATE,
        MEMO        = ?
       WHERE MSC = ? AND INDEX_SEQ = ?  AND INDEX_SEQ_C = ? AND VALIDFLAG='1'
		]]>
	</query>
</queryMap>