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

<sqlMap namespace="BapSystemID">

    <statement id="selectList" resultClass="java.util.HashMap">
        SELECT 
               	ROWNO AS "ROWNO",
               	SYSTEMID		,
               	BJOBBZWKDSTCD	,
               	BJOBBZWKNAME	,
               	OSIDINSTINAME	,
				OSIDINSTIDSTCD	,
				RMTNODENAME
        FROM (
            SELECT
            	ROW_NUMBER() OVER(ORDER BY BA07.SYSTEMID, BA07.BJOBBZWKDSTCD) ROWNO,
				BA07.SYSTEMID,
				BA07.BJOBBZWKDSTCD,
				BA07.OSIDINSTIDSTCD,
				BJ02.BJOBBZWKNAME,
				BJ06.OSIDINSTINAME,
				BA07.RMTNODENAME
			FROM
				$schemaId$.TSEAIBA07 BA07 
				LEFT JOIN $schemaId$.TSEAIBJ02 BJ02 ON BA07.BJOBBZWKDSTCD=BJ02.BJOBBZWKDSTCD
				LEFT JOIN $schemaId$.TSEAIBJ06 BJ06 ON BJ06.OSIDINSTIDSTCD = BA07.OSIDINSTIDSTCD
			<dynamic prepend="WHERE">
				<isNotEmpty prepend="AND" property="searchSystemId" >
	        		UPPER(BA07.SYSTEMID) LIKE CONCAT( '%'  ,  #searchSystemId#   ,  '%')
	        	</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchSystemName" >
	        		UPPER(BA07.SYSTEMNAME) LIKE CONCAT('%' ,  #searchSystemName#   ,  '%')
	        	</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchOsidInstiName" >
	        		UPPER(BJ06.OSIDINSTINAME) LIKE CONCAT('%' ,  #searchOsidInstiName#   ,  '%')
	        	</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchBjobBzwkName" >
	        		UPPER(BJ02.BJOBBZWKNAME) LIKE CONCAT('%' ,  #searchBjobBzwkName#   ,  '%')
	        	</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchBjobBzwkDstcd" >
	        		UPPER(BA07.BJOBBZWKDSTCD) LIKE CONCAT('%' ,  #searchBjobBzwkDstcd#   ,  '%')
	        	</isNotEmpty>
	   			<isNotEmpty prepend="AND" property="searchRmtNodeName" >
	           		UPPER(BA07.RMTNODENAME) LIKE CONCAT('%' ,  #searchRmtNodeName#   ,  '%')
	           	</isNotEmpty>
	        </dynamic>
           ) TMP
         WHERE ROWNO BETWEEN #startNum# AND #endNum#
    </statement>

    <statement id="selectListCount" resultClass="java.lang.Integer">
        SELECT
			COUNT(*) AS "TOTALCOUNT"
		FROM
			$schemaId$.TSEAIBA07 BA07 
			LEFT JOIN $schemaId$.TSEAIBJ02 BJ02 ON BA07.BJOBBZWKDSTCD=BJ02.BJOBBZWKDSTCD
			LEFT JOIN $schemaId$.TSEAIBJ06 BJ06 ON BJ06.OSIDINSTIDSTCD = BA07.OSIDINSTIDSTCD
		<dynamic prepend="WHERE">
			<isNotEmpty prepend="AND" property="searchSystemId" >
        		UPPER(BA07.SYSTEMID) LIKE CONCAT( '%'  ,  #searchSystemId#   ,  '%')
        	</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchSystemName" >
        		UPPER(BA07.SYSTEMNAME) LIKE CONCAT('%' ,  #searchSystemName#   ,  '%')
        	</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchOsidInstiName" >
        		UPPER(BJ06.OSIDINSTINAME) LIKE CONCAT('%' ,  #searchOsidInstiName#   ,  '%')
        	</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchBjobBzwkName" >
        		UPPER(BJ02.BJOBBZWKNAME) LIKE CONCAT('%' ,  #searchBjobBzwkName#   ,  '%')
        	</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchBjobBzwkDstcd" >
        		UPPER(BA07.BJOBBZWKDSTCD) LIKE CONCAT('%' ,  #searchBjobBzwkDstcd#   ,  '%')
        	</isNotEmpty>
   			<isNotEmpty prepend="AND" property="searchRmtNodeName" >
           		UPPER(BA07.RMTNODENAME) LIKE CONCAT('%' ,  #searchRmtNodeName#   ,  '%')
           	</isNotEmpty>
        </dynamic>
    </statement>

    <statement id="selectDetail" resultClass="java.util.HashMap">
        SELECT
			BA07.SYSTEMID,
			BA07.BJOBBZWKDSTCD,
			BA07.OSIDINSTIDSTCD,
			BA07.RMTNODENAME
		FROM
			$schemaId$.TSEAIBA07 BA07 
			LEFT JOIN $schemaId$.TSEAIBJ02 BJ02 ON BA07.BJOBBZWKDSTCD=BJ02.BJOBBZWKDSTCD
			LEFT JOIN $schemaId$.TSEAIBJ06 BJ06 ON BJ06.OSIDINSTIDSTCD = BA07.OSIDINSTIDSTCD
		WHERE
			SYSTEMID = #systemId#
    </statement>

    <statement id="insert" resultClass="java.lang.Integer">
        INSERT INTO $schemaId$.TSEAIBA07 (
			SYSTEMID,
			BJOBBZWKDSTCD,
			OSIDINSTIDSTCD,
			RMTNODENAME)
		VALUES(
			#systemId#,
			#bJobBzwkDstcd#,
			#osidInstiDstcd#,
			#rmtNodeName#
		)
    </statement>

    <statement id="update" resultClass="java.lang.Integer">
        UPDATE $schemaId$.TSEAIBA07
		SET 
			BJOBBZWKDSTCD	=	#bJobBzwkDstcd#	, 
			OSIDINSTIDSTCD	=	#osidInstiDstcd#, 
			RMTNODENAME		=	#rmtNodeName#
		WHERE SYSTEMID = #systemId#
    </statement>

    <statement id="delete" resultClass="java.lang.Integer">
        DELETE FROM $schemaId$.TSEAIBA07 WHERE SYSTEMID = #systemId#
    </statement>
</sqlMap>