<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="SocketPort">

<statement id="selectListCount" resultClass="java.lang.Integer">
		SELECT 	COUNT(*) AS "TOTALCOUNT"
			FROM  $schemaId$.TSEAIRM31
			<dynamic prepend="WHERE">
				<isEmpty property ="searchAdptrPort">
					<isNotEmpty prepend="AND" property="searchEaiSevrDstCd">
						EAISEVRDSTCD  = #searchEaiSevrDstCd#
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrBzwkNameDesc">
						RECVADPTRDESC LIKE '%' || #searchAdptrBzwkNameDesc# || '%'  OR  SENDADPTRDESC LIKE '%' || #searchAdptrBzwkNameDesc# || '%'
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrBzwkName">
						UPPER(RECVADPTRBZWKNAME) LIKE '%' || UPPER(#searchAdptrBzwkName#) || '%'  OR  UPPER(SENDADPTRBZWKNAME) LIKE '%' || UPPER(#searchAdptrBzwkName#) || '%'
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrPort">
						RECVTESTPORT LIKE '%' ||  #searchAdptrPort# || '%' OR RECVREALPORT LIKE '%' ||  #searchAdptrPort# || '%'
					</isNotEmpty>
				</isEmpty>
				<isNotEmpty property ="searchAdptrPort">
					<isNotEmpty prepend="AND" property="searchAdptrBzwkNameDesc">
						RECVADPTRDESC LIKE '%' || #searchAdptrBzwkNameDesc# || '%'  OR  SENDADPTRDESC LIKE '%' || #searchAdptrBzwkNameDesc# || '%'
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrBzwkName">
						UPPER(RECVADPTRBZWKNAME) LIKE '%' || UPPER(#searchAdptrBzwkName#) || '%'  OR  UPPER(SENDADPTRBZWKNAME) LIKE '%' || UPPER(#searchAdptrBzwkName#) || '%'
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrPort">						 
						RECVTESTPORT LIKE '%' ||  #searchAdptrPort# || '%' OR RECVREALPORT LIKE '%' ||  #searchAdptrPort# || '%'
					</isNotEmpty>
				</isNotEmpty>
			</dynamic>	
	</statement>

 <statement id="selectList" resultClass="java.util.HashMap">
		SELECT 
			  ROWNO AS "ROWNO"
			, EAISEVRDSTCD AS "EAISEVRDSTCD"
		    , RECVADPTRBZWKNAME AS "RECVADPTRBZWKNAME"
		    , RECVADPTRDESC AS "RECVADPTRDESC"
		    , RECVTESTPORT AS "RECVTESTPORT"
		    , RECVREALPORT AS "RECVREALPORT"
		    , RECVPORTLASTYMD AS "RECVPORTLASTYMD"
		    , RECVLASTADMUSERID AS "RECVLASTADMUSERID"
		    , SENDADPTRBZWKNAME AS "SENDADPTRBZWKNAME"
		    , SENDADPTRDESC AS "SENDADPTRDESC"
		    , SENDTESTPORT AS "SENDTESTPORT"
			, SENDREALPORT AS "SENDREALPORT"
		    , SENDPORTLASTYMD AS "SENDPORTLASTYMD"
		    , SENDLASTADMUSERID AS "SENDLASTADMUSERID"
		FROM (
		 <isEqual compareValue="ASC" property="searchOrderType">
            SELECT  ROW_NUMBER() OVER (ORDER BY EAISEVRDSTCD, RECVTESTPORT ) AS ROWNO 
         </isEqual>
         <isEqual compareValue="DESC" property="searchOrderType">
            SELECT  ROW_NUMBER() OVER (ORDER BY EAISEVRDSTCD, RECVTESTPORT DESC) AS ROWNO 
         </isEqual>  
			    , EAISEVRDSTCD
			    , RECVADPTRBZWKNAME
			    , RECVADPTRDESC
			    , RECVTESTPORT
			    , RECVREALPORT
			    , RECVPORTLASTYMD
			    , RECVLASTADMUSERID
			    , SENDADPTRBZWKNAME
			    , SENDADPTRDESC
			    , SENDTESTPORT
				, SENDREALPORT
			    , SENDPORTLASTYMD
			    , SENDLASTADMUSERID
		FROM  $schemaId$.TSEAIRM31
			<dynamic prepend="WHERE">
				<isEmpty property ="searchAdptrPort">
					<isNotEmpty prepend="AND" property="searchEaiSevrDstCd">
						EAISEVRDSTCD  = #searchEaiSevrDstCd#
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrBzwkNameDesc">
						RECVADPTRDESC LIKE '%' || #searchAdptrBzwkNameDesc# || '%'  OR  SENDADPTRDESC LIKE '%' || #searchAdptrBzwkNameDesc# || '%'
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrBzwkName">
						UPPER(RECVADPTRBZWKNAME) LIKE '%' || UPPER(#searchAdptrBzwkName#) || '%'  OR  UPPER(SENDADPTRBZWKNAME) LIKE '%' || UPPER(#searchAdptrBzwkName#) || '%'
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrPort">
						RECVTESTPORT LIKE '%' ||  #searchAdptrPort# || '%' OR RECVREALPORT LIKE '%' ||  #searchAdptrPort# || '%'
					</isNotEmpty>
				</isEmpty>
				<isNotEmpty property ="searchAdptrPort">
					<isNotEmpty prepend="AND" property="searchAdptrBzwkNameDesc">
						RECVADPTRDESC LIKE '%' || #searchAdptrBzwkNameDesc# || '%'  OR  SENDADPTRDESC LIKE '%' || #searchAdptrBzwkNameDesc# || '%'
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrBzwkName">
						UPPER(RECVADPTRBZWKNAME) LIKE '%' || UPPER(#searchAdptrBzwkName#) || '%'  OR  UPPER(SENDADPTRBZWKNAME) LIKE '%' || UPPER(#searchAdptrBzwkName#) || '%'
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrPort">
						RECVTESTPORT LIKE '%' || #searchAdptrPort# || '%' OR RECVREALPORT LIKE '%' || #searchAdptrPort# || '%'
					</isNotEmpty>
				</isNotEmpty>
			</dynamic>						
			) ORGTABLE
		WHERE ROWNO BETWEEN #startNum# AND #endNum#
	</statement>	
	
 	<statement id="selectAllList" resultClass="java.util.HashMap">
			 <isEqual compareValue="ASC" property="searchOrderType">
	            SELECT  ROW_NUMBER() OVER (ORDER BY EAISEVRDSTCD, RECVTESTPORT ) AS ROWNO 
	         </isEqual>
	         <isEqual compareValue="DESC" property="searchOrderType">
	            SELECT  ROW_NUMBER() OVER (ORDER BY EAISEVRDSTCD, RECVTESTPORT DESC) AS ROWNO 
	         </isEqual>   
			    , EAISEVRDSTCD
			    , RECVADPTRBZWKNAME
			    , RECVADPTRDESC
			    , RECVTESTPORT
			    , RECVREALPORT
			    , RECVPORTLASTYMD
			    , RECVLASTADMUSERID
			    , SENDADPTRBZWKNAME
			    , SENDADPTRDESC
			    , SENDTESTPORT
				, SENDREALPORT
			    , SENDPORTLASTYMD
			    , SENDLASTADMUSERID
		FROM  $schemaId$.TSEAIRM31
		<dynamic prepend="WHERE">
				<isEmpty property ="searchAdptrPort">
					<isNotEmpty prepend="AND" property="searchEaiSevrDstCd">
						EAISEVRDSTCD  = #searchEaiSevrDstCd#
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrBzwkNameDesc">
						RECVADPTRDESC LIKE '%' || #searchAdptrBzwkNameDesc# || '%'  OR  SENDADPTRDESC LIKE '%' || #searchAdptrBzwkNameDesc# || '%'
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrBzwkName">
						UPPER(RECVADPTRBZWKNAME) LIKE '%' || UPPER(#searchAdptrBzwkName#) || '%'  OR  UPPER(SENDADPTRBZWKNAME) LIKE '%' || UPPER(#searchAdptrBzwkName#) || '%'
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrPort">
						RECVTESTPORT LIKE '%' ||  #searchAdptrPort# || '%' OR RECVREALPORT LIKE '%' ||  #searchAdptrPort# || '%'
					</isNotEmpty>
				</isEmpty>
				<isNotEmpty property ="searchAdptrPort">
					<isNotEmpty prepend="AND" property="searchAdptrBzwkNameDesc">
						RECVADPTRDESC LIKE '%' || #searchAdptrBzwkNameDesc# || '%'  OR  SENDADPTRDESC LIKE '%' || #searchAdptrBzwkNameDesc# || '%'
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrBzwkName">
						UPPER(RECVADPTRBZWKNAME) LIKE '%' || UPPER(#searchAdptrBzwkName#) || '%'  OR  UPPER(SENDADPTRBZWKNAME) LIKE '%' || UPPER(#searchAdptrBzwkName#) || '%'
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrPort">
						RECVTESTPORT LIKE '%' || #searchAdptrPort# || '%' OR RECVREALPORT LIKE '%' || #searchAdptrPort# || '%'
					</isNotEmpty>
				</isNotEmpty>
			</dynamic>					
	</statement>	

	<statement id="selectInitPort" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
		SELECT COALESCE(MAX(RECVTESTPORT)+1,#resvTportSt#) AS ASSIGNPORT  
		  	FROM $schemaId$.TSEAIRM31
		 WHERE RECVTESTPORT BETWEEN #resvTportSt# AND  #resvTportEn# 
		 UNION ALL
		  SELECT COALESCE(MAX(RECVREALPORT)+1,#resvRportSt#) AS ASSIGNPORT  
		   FROM $schemaId$.TSEAIRM31
		WHERE RECVREALPORT BETWEEN #resvRportSt# AND  #resvRportEn# 
		 UNION ALL
		 SELECT COALESCE(MAX(SENDTESTPORT)+1,#sendTportSt#) AS ASSIGNPORT  
		  FROM $schemaId$.TSEAIRM31
		WHERE SENDTESTPORT BETWEEN #sendTportSt# AND  #sendTportEn# 
		 UNION ALL
		 SELECT COALESCE(MAX(SENDREALPORT)+1, #sendRportSt#) AS ASSIGNPORT  
		  FROM $schemaId$.TSEAIRM31
		WHERE SENDREALPORT BETWEEN #sendRportSt# AND  #sendRportEn#
	</statement>
	
	<statement id="selectListToExcel" resultClass="java.util.HashMap">
		SELECT 
			  $headersStr$
		FROM (
              SELECT  EAISEVRDSTCD
				    , RECVADPTRBZWKNAME
				    , RECVADPTRDESC
				    , RECVTESTPORT
				    , RECVREALPORT
				    , RECVPORTLASTYMD
				    , RECVLASTADMUSERID
				    , SENDADPTRBZWKNAME
				    , SENDADPTRDESC
				    , SENDTESTPORT
					, SENDREALPORT
				    , SENDPORTLASTYMD
				    , SENDLASTADMUSERID
			FROM  $schemaId$.TSEAIRM31
			<dynamic prepend="WHERE">
				<isEmpty property ="searchAdptrPort">
					<isNotEmpty prepend="AND" property="searchEaiSevrDstCd">
						EAISEVRDSTCD  = #searchEaiSevrDstCd#
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrBzwkNameDesc">
						RECVADPTRDESC LIKE '%' || #searchAdptrBzwkNameDesc# || '%'  OR  SENDADPTRDESC LIKE '%' || #searchAdptrBzwkNameDesc# || '%'
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrBzwkName">
						UPPER(RECVADPTRBZWKNAME) LIKE '%' || UPPER(#searchAdptrBzwkName#) || '%'  OR  UPPER(SENDADPTRBZWKNAME) LIKE '%' || UPPER(#searchAdptrBzwkName#) || '%'
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrPort">
						RECVTESTPORT LIKE '%' || #searchAdptrPort# || '%' OR RECVREALPORT LIKE '%' || #searchAdptrPort# || '%' 
					</isNotEmpty>
				</isEmpty>
				<isNotEmpty property ="searchAdptrPort">
					<isNotEmpty prepend="AND" property="searchAdptrBzwkNameDesc">
						RECVADPTRDESC LIKE '%' || #searchAdptrBzwkNameDesc# || '%'  OR  SENDADPTRDESC LIKE '%' || #searchAdptrBzwkNameDesc# || '%'
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrBzwkName">
						UPPER(RECVADPTRBZWKNAME) LIKE '%' || UPPER(#searchAdptrBzwkName#) || '%'  OR  UPPER(SENDADPTRBZWKNAME) LIKE '%' || UPPER(#searchAdptrBzwkName#) || '%'
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrPort">
						RECVTESTPORT LIKE '%' || #searchAdptrPort# || '%' OR RECVREALPORT LIKE '%' || #searchAdptrPort# || '%' 
					</isNotEmpty>
				</isNotEmpty>
			</dynamic>
			) TMP1
		 <isEqual compareValue="ASC" property="searchOrderType">
            ORDER BY EAISEVRDSTCD, RECVTESTPORT
         </isEqual>
         <isEqual compareValue="DESC" property="searchOrderType">
           ORDER BY EAISEVRDSTCD, RECVTESTPORT DESC
         </isEqual>  
			
	</statement>	

</sqlMap>
