<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="COM_BASE_PURCHASE_AGREEMENT （生成工具：代码生成工具4.0   访问地址：http://172.16.2.128/tool/）">
    <query id="ComBasePurchaseAgreementDAL.Query" desc="查询">
        <![CDATA[
SELECT T.AGREEMENT_CODE,
       T.AGREEMENT_DESC,
       TO_CHAR(T.SIGNING_DATE, 'YYYY-MM-DD HH24:MI:SS') SIGNING_DATE,
       T.MEMO,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.DELETE_NAME,
       TO_CHAR(T.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       DECODE(T.VALIDFLAG, '1', '有效', '0', '无效') VALIDFLAG,
       (SELECT LISTAGG(A.SUPP_CODE, ';') WITHIN GROUP(ORDER BY A.SUPP_CODE)
          FROM COM_BASE_PURCHASE_PROVIDER A
         WHERE A.AGREEMENT_CODE = T.AGREEMENT_CODE) SUPP_CODES,
       (SELECT LISTAGG(A.SUPP_NAME, ';') WITHIN GROUP(ORDER BY A.SUPP_NAME)
          FROM COM_BASE_PURCHASE_PROVIDER A
         WHERE A.AGREEMENT_CODE = T.AGREEMENT_CODE) SUPP_DESCS,
       T.STD_CODE_NK,
       T.STD_NAME_NK
  FROM COM_BASE_PURCHASE_AGREEMENT T
 WHERE #AGREEMENT_DESC#
   AND T.VALIDFLAG IN ('1', '#VALIDFLAG#')

        ]]>
    </query>
    <query id="ComBasePurchaseAgreementDAL.QueryByPk" desc="通过主键查询">
        <![CDATA[
SELECT T.AGREEMENT_CODE,
       T.AGREEMENT_DESC,
       TO_CHAR(T.SIGNING_DATE, 'YYYY-MM-DD HH24:MI:SS') SIGNING_DATE,
       T.MEMO,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.DELETE_NAME,
       TO_CHAR(T.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       T.VALIDFLAG,
       T.STD_CODE_NK,
       T.STD_NAME_NK
  FROM COM_BASE_PURCHASE_AGREEMENT T
 WHERE T.AGREEMENT_CODE = '#AGREEMENT_CODE#'
        ]]>
    </query>
    <query id="ComBasePurchaseAgreementDAL.Insert" desc="新增">
        <![CDATA[
 INSERT INTO COM_BASE_PURCHASE_AGREEMENT(
        AGREEMENT_CODE,
        AGREEMENT_DESC,
        SIGNING_DATE,
        MEMO,
        CREATE_NAME,
        CREATE_TIME,
        STD_CODE_NK,
        STD_NAME_NK)
 VALUES( 
        '#AGREEMENT_CODE#',
        '#AGREEMENT_DESC#',
        TO_DATE('#SIGNING_DATE#', 'YYYY-MM-DD HH24:MI:SS'),
        '#MEMO#',
        '#CREATE_NAME#',
        SYSDATE,
        '#STD_CODE_NK#',
        '#STD_NAME_NK#')
        ]]>
    </query>
    <query id="ComBasePurchaseAgreementDAL.Update" desc="修改">
        <![CDATA[
 UPDATE COM_BASE_PURCHASE_AGREEMENT T
   SET 
        T.AGREEMENT_CODE = '#AGREEMENT_CODE#',
        T.AGREEMENT_DESC = '#AGREEMENT_DESC#',
        T.SIGNING_DATE = TO_DATE('#SIGNING_DATE#', 'YYYY-MM-DD HH24:MI:SS'),
        T.MEMO = '#MEMO#',
        T.UPDATE_NAME = '#UPDATE_NAME#',
        T.UPDATE_TIME = SYSDATE,
        T.STD_CODE_NK = '#STD_CODE_NK#',
        T.STD_NAME_NK = '#STD_NAME_NK#'
 WHERE
       T.AGREEMENT_CODE = '#AGREEMENT_CODE#'
        ]]>
    </query>
    <query id="ComBasePurchaseAgreementDAL.GetMaxPk" desc="获取最大主键">
        <![CDATA[
SELECT LPAD(NVL(MAX(AGREEMENT_CODE), 0) + 1, 5, '0') MAX_VALUE
  FROM COM_BASE_PURCHASE_AGREEMENT T
        ]]>
    </query>
    <query id="ComBasePurchaseAgreementDAL.Delete" desc="作废">
        <![CDATA[
UPDATE COM_BASE_PURCHASE_AGREEMENT T
   SET
       T.VALIDFLAG = '0',
       T.DELETE_NAME = '#DELETE_NAME#',
       T.DELETE_TIME = SYSDATE
WHERE
       T.AGREEMENT_CODE = '#AGREEMENT_CODE#'
        ]]>
    </query>
    <query id="ComBasePurchaseAgreementDAL.Resume" desc="恢复">
        <![CDATA[
UPDATE COM_BASE_PURCHASE_AGREEMENT T
   SET
       T.VALIDFLAG = '1',
       T.DELETE_NAME = NULL,
       T.DELETE_TIME = NULL,
       T.UPDATE_NAME = '#UPDATE_NAME#',
       T.UPDATE_TIME = SYSDATE
WHERE
       T.AGREEMENT_CODE = '#AGREEMENT_CODE#'
        ]]>
    </query>
    <query id="ComBasePurchaseAgreementDAL.Clear" desc="清除向下的数据">
        <![CDATA[
DECLARE
 BEGIN
   DELETE FROM (SELECT *
                  FROM COM_BASE_PURCHASE_PROVIDER T
                 WHERE T.AGREEMENT_CODE = '#AGREEMENT_CODE#');
   DELETE FROM (SELECT *
                  FROM COM_BASE_PURCHASE_STD_IDX T
                 WHERE T.AGREEMENT_CODE = '#AGREEMENT_CODE#');
 END;
        ]]>
    </query>
</queryMap>