<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="下拉框动态数据获取管理">
	 
	 <query id="CoreWaterRatioRStd.GetStd" desc="标准基础">
		<![CDATA[	
SELECT DISTINCT T.STD_CODE, T.STD_NAME, T.STD_STYLE, T.STD_STYLE_DESC
  FROM COM_PSC T
 WHERE T.VALIDFLAG = '1'
   AND NOT EXISTS (SELECT 1
          FROM COM_BASE_WATER_RATIO B
         WHERE B.STD_CODE = T.STD_CODE
           AND B.STD_STYLE = T.STD_STYLE)
 ORDER BY STD_NAME, STD_STYLE_DESC
		]]>
	</query>
	
	 <query id="CoreWaterRatioRStd.GetStdReplace" desc="标准基础">
		<![CDATA[	
SELECT DISTINCT T.STD_CODE, T.STD_NAME, T.STD_STYLE, T.STD_STYLE_DESC
  FROM COM_BASE_WATER_RATIO T
 WHERE T.VALIDFLAG = '1'
 ORDER BY STD_NAME, STD_STYLE_DESC
		]]>
	</query>
	
	 <query id="CoreWaterRatioRStd.IsExistStdAdd" desc="标准基础">
		<![CDATA[	
        SELECT 1
        FROM COM_BASE_WATER_RATIO_STD T
        WHERE T.STD_CODE_C =?
        AND  '&'||T.STD_STYLE_C= '&'||?  
        OR EXISTS(
        SELECT 1 FROM COM_BASE_WATER_RATIO T1 
        WHERE T1.STD_CODE = ?)
        --一个标准只能引用一个水压标准,一个水压标准可被多个标准引用,且所选标准不再水压标准基础维护中
		]]>
	</query>
	
	<query id="CoreWaterRatioRStd.IsExistStdUpdate" desc="标准基础">
		<![CDATA[	
        SELECT 1
        FROM COM_BASE_WATER_RATIO_STD T
        WHERE T.STD_CODE_C =? AND T.STD_CODE_C !=?
        AND  '&'||T.STD_STYLE_C= '&'||?  
        OR EXISTS(
        SELECT 1 FROM COM_BASE_WATER_RATIO T1 
        WHERE T1.STD_CODE = ? AND T1.STD_CODE != ?)
        --一个标准只能引用一个水压标准,一个水压标准可被多个标准引用,且所选标准不再水压标准基础维护中
		]]>
	</query>
	
	<query id="CoreWaterRatioRStd.AddStd" desc="新增">
	<![CDATA[
	 INSERT INTO COM_BASE_WATER_RATIO_STD
   (ID_,
   STD_CODE_C,
   STD_NAME_C,
   STD_STYLE_C,
   STD_STYLE_DESC_C,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   CREATE_NAME,
   CREATE_TIME,
   MEMO)
   VALUES
   (?,?,?,?,?,?,?,?,?,?,SYSDATE,?)
	 
	]]>
	</query>
	
	<query id="CoreWaterRatioRStd.UpdateStd" desc="修改">
		<![CDATA[	
       UPDATE COM_BASE_WATER_RATIO_STD
       SET ID_           = ?,
        STD_CODE_C       = ?,
        STD_NAME_C       = ?,
        STD_STYLE_C      = ?,
        STD_STYLE_DESC_C = ?,
        STD_CODE         = ?,
        STD_NAME         = ?,
        STD_STYLE        = ?,
        STD_STYLE_DESC   = ?,
        UPDATE_NAME      = ?,
        UPDATE_TIME      = SYSDATE,
        MEMO             = ?
        WHERE ID_        = ?
      
		]]>
	</query>
	
	<query id="CoreWaterRatioRStd.QUERY" desc="关联查询">
		<![CDATA[	
       SELECT ID_,
       STD_CODE_C ,
       STD_NAME_C,
       STD_CODE_C STD_CODE_OLD,
       STD_STYLE_C,
       STD_STYLE_DESC_C,
       STD_CODE,
       STD_NAME,
       STD_STYLE,
       STD_STYLE_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','有效','无效') VALIDFLAG,
       MEMO
    FROM COM_BASE_WATER_RATIO_STD
    WHERE VALIDFLAG IN ('1',?)
		]]>
	</query>
	
	<query id="CoreWaterRatioRStd.DeleteStd" desc="关联查询">
		<![CDATA[
DELETE FROM COM_BASE_WATER_RATIO_STD T WHERE T.ID_ = '#ID_#'
		]]>
	</query>
	
	
	<query id="CoreWaterRatioRStd.ResumeStd" desc="关联增加">
		<![CDATA[	
            UPDATE COM_BASE_WATER_RATIO_STD
        SET  
        DELETE_NAME      = '',
        DELETE_TIME      = '',
        VALIDFLAG        = '1'
        WHERE ID_        = ?
        AND  VALIDFLAG ='0'
 
		]]>
	</query>
	
	 
	   
</queryMap>