<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="本地计量模板">



    <query id="TemplateServer.doQueryTempate" desc="查询模板">
        <![CDATA[
             SELECT * FROM CMM_RECORD_TEMPLATE WHERE  VALIDFLAG = '1'
        ]]>
    </query>

    <query  id="TemplateServer.doSaveTemplate" desc="保存模板">
        <![CDATA[
    INSERT INTO CMM_RECORD_TEMPLATE(
        TEMPLATE_NO,
        TEMPLATE_NAME,
        TEMPLATE_LOCATION,
        TEMPLATE_KEY,
        TEMPLATE_XML,
        VALIDFLAG,
        CREATE_USER,
        CREATE_DATE)
 VALUES(
         (SELECT  TO_CHAR(SYSDATE, 'yyyyMMDD') ||
    LPAD(NVL(MAX(TO_NUMBER(SUBSTR(TEMPLATE_NO, LENGTH(TEMPLATE_NO) - 2))),
    0) + 1,
    3,
    '0') TEMPLATE_NO
    FROM  CMM_RECORD_TEMPLATE
    WHERE TEMPLATE_NO LIKE  TO_CHAR(SYSDATE, 'yyyyMMDD') || '___'),
        '#TEMPLATE_NAME#',
        '#TEMPLATE_LOCATION#',
        '#TEMPLATE_KEY#',
        '#TEMPLATE_XML#',
        '1',
        '#CREATE_USER#',
        SYSDATE)
           ]]>
    </query>

    <query  id="TemplateServer.DoDeleteTemplate" desc="作废模板">
        <![CDATA[
    UPDATE CMM_RECORD_TEMPLATE
      SET VALIDFLAG ='0',
      DELETE_USER = ?,
      DELETE_DATE = SYSDATE
      WHERE TEMPLATE_NO = ?
           ]]>
    </query>

    <query  id="TemplateServer.DoDeleteTemplate2" desc="作废模板">
        <![CDATA[
    UPDATE CMM_RECORD_TEMPLATE
      SET VALIDFLAG ='0',
      DELETE_USER = ?,
      DELETE_DATE = SYSDATE
      WHERE TEMPLATE_NAME = ?
           ]]>
    </query>

</queryMap>