<?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="Biz">
	<statement id="selectDetail" resultClass="java.util.HashMap">
		SELECT 	EaiBzwkDstcd AS "EAIBZWKDSTCD" ,
		        BzwkDsticName AS "BZWKDSTICNAME",
		        BzwkDsticDesc AS "BZWKDSTICDESC"
	            FROM $schemaId$.TSEAICM01   
	    WHERE EaiBzwkDstcd = #eaiBzwkDstcd#
	</statement>  
	
	<statement id="update" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
		UPDATE 	$schemaId$.TSEAICM01 SET
		        BzwkDsticName = #eaiBzwkDsticName#, 
				BzwkDsticDesc = #bzwkDsticDesc#
		WHERE 	BzwkDstcd     = #bzwkDstcd#
	</statement>
	
	<statement id="insert" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
		INSERT 	INTO $schemaId$.TSEAICM01(
				EaiBzwkDstcd,
				BzwkDsticName,
				BzwkDsticDesc) 
		VALUES (#eaiBzwkDstcd# ,
		        #bzwkDsticName#,
				#bzwkDsticDesc#
				)
	</statement>
	
	<statement id="delete" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
		DELETE 	FROM $schemaId$.TSEAICM01 WHERE EaiBzwkDstcd = #eaiBzwkDstcd#
	</statement>
	
	<statement id="insertUserBiz" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
	 	INSERT INTO $schemaId$.TSEAIRM06(USERID, EAIBZWKDSTCD, SAVETYPE) 
		VALUES	(#userId#, #BIZCODE# ,#SAVETYPE#)	
	</statement>		
	
	<statement id="deleteUserBiz" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
	 	DELETE 	FROM $schemaId$.TSEAIRM06 
	 	WHERE 	USERID = #userId# 
	 	<isNotEmpty prepend="AND" property="SAVETYPE">
	 	 SAVETYPE = #SAVETYPE#
	 	</isNotEmpty>
	</statement>
	
	<statement id="deleteUserBizCode" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
	 	DELETE 	FROM $schemaId$.TSEAIRM06 
	 	WHERE 	USERID = #userId# 
	 	AND EAIBZWKDSTCD = #BIZCODE#
	</statement>
	
	<statement id="mergeRM06" parameterClass="java.util.HashMap">
	 MERGE INTO $schemaId$.TSEAIRM06 RM06  USING
		(VALUES (#userId# , #EAIBZWKDSTCD#, #SAVETYPE#))					
		INSROW (USERID , EAIBZWKDSTCD , SAVETYPE)
	 ON RM06.USERID = INSROW.USERID AND RM06.EAIBZWKDSTCD = INSROW.EAIBZWKDSTCD
		WHEN NOT MATCHED THEN
	 INSERT VALUES (INSROW.USERID ,INSROW.EAIBZWKDSTCD , INSROW.SAVETYPE) 
	</statement>
	
	
	<statement id="selectUserBizCodes" resultClass="java.util.HashMap">
		SELECT C01.EAIBZWKDSTCD  AS "BIZCODE"
			 , C01.BZWKDSTICNAME AS "BIZNAME"
			 , C01.BZWKDSTICDESC AS "BIZDESC"
	      FROM $schemaId$.TSEAICM01 C01
	         , $schemaId$.TSEAIRM06 R06
	      WHERE C01.EAIBZWKDSTCD = R06.EAIBZWKDSTCD	
	        AND R06.USERID = #userId# 
	     order by 1	
	</statement>
	
	<statement id="selectUserEaiBizCodes" resultClass="java.util.HashMap">
		SELECT 
			C01.EAIBZWKDSTCD  AS "BIZCODE", 
			C01.BZWKDSTICNAME AS "BIZNAME", 
			C01.BZWKDSTICDESC AS "BIZDESC"
		FROM 
			$schemaId$.TSEAICM01 C01, 
			$schemaId$.TSEAIRM06 R06
		WHERE 
			C01.EAIBZWKDSTCD = R06.EAIBZWKDSTCD
		AND
			C01.INPUTDSTCD = 'APP'	
		AND 
			R06.USERID = #userId#
		ORDER BY 1
	</statement>
	
	<statement id="selectUserExtBizCodes" resultClass="java.util.HashMap">
		SELECT 
			C01.EAIBZWKDSTCD  AS "BIZCODE", 
			C01.BZWKDSTICNAME AS "BIZNAME", 
			C01.BZWKDSTICDESC AS "BIZDESC"
		FROM 
			$schemaId$.TSEAICM01 C01, 
			$schemaId$.TSEAIRM06 R06
		WHERE 
			C01.EAIBZWKDSTCD = R06.EAIBZWKDSTCD
		AND
			C01.INPUTDSTCD = 'EXT'	
		AND 
			R06.USERID = #userId#
		ORDER BY 1
	</statement>
	
	
	<statement id="selectChgAdptUserBizCodes" resultClass="java.util.HashMap">
		SELECT C01.EAIBZWKDSTCD  AS "BIZCODE"
			 , C01.BZWKDSTICNAME AS "BIZNAME"
			 , C01.BZWKDSTICDESC AS "BIZDESC"
	      FROM $schemaId$.TSEAICM01 C01
	     WHERE C01.EAIBZWKDSTCD != 'EAI'
	     order by 1	
	</statement>
	
	<statement id="selectBizList" resultClass="java.util.HashMap">
		SELECT C01.EAIBZWKDSTCD  AS "BIZCODE"
			 , C01.BZWKDSTICNAME AS "BIZNAME"
			 , C01.BZWKDSTICDESC AS "BIZDESC"
	      FROM $schemaId$.TSEAICM01 C01
	     order by 1
	</statement>
		
	<statement id="selectEaiBizList" resultClass="java.util.HashMap">
		SELECT 
			C01.EAIBZWKDSTCD  AS "BIZCODE", 
			C01.BZWKDSTICNAME AS "BIZNAME", 
			C01.BZWKDSTICDESC AS "BIZDESC"
		FROM 
			$schemaId$.TSEAICM01 C01
		WHERE
			C01.INPUTDSTCD = 'APP'
		ORDER BY 1
	</statement>
		
	<statement id="selectExtBizList" resultClass="java.util.HashMap">
		SELECT 
			SUBSTR(C01.EAIBZWKDSTCD, 2, 3) AS "BIZCODE", 
			C01.BZWKDSTICNAME AS "BIZNAME", 
			C01.BZWKDSTICDESC AS "BIZDESC"
		FROM 
			$schemaId$.TSEAICM01 C01
		WHERE
			C01.INPUTDSTCD = 'EXT'
		ORDER BY 1
	</statement>
	
	<statement id="selectAdapterBizList" resultClass="java.util.HashMap">
		SELECT C01.EAIBZWKDSTCD  AS "BIZCODE"
			 , C01.BZWKDSTICNAME AS "BIZNAME"
			 , C01.BZWKDSTICDESC AS "BIZDESC"
	      FROM $schemaId$.TSEAICM01 C01
	      <dynamic prepend="WHERE">
	      	<isNotEmpty prepend="AND" property="searchBzwkName">
	      	 UPPER(C01.EAIBZWKDSTCD) = UPPER(#searchBzwkName#)
	      	</isNotEmpty>
	      </dynamic>
	     order by 1
	</statement>
	
	<statement id="deleteUserBizCodeRole" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
		DELETE 	FROM $schemaId$.TSEAIRM06 WHERE USERID IN ($USERIDS$)
	</statement>
	
	<statement id="selectChgAdptUserBizCode"  parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
		SELECT
			COUNT(*)
		FROM $schemaId$.TSEAIRM06 
		WHERE USERID = #userId#
		AND EAIBZWKDSTCD = #bzwkdstcd#
	</statement>	
	
</sqlMap>
