<?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="FlowRule">
  
    <statement id="detail" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
		SELECT 
			BJOBBZWKPRCSSDSTCD AS "BJOBBZWKPRCSSDSTCD",
            FLOWRULEPTRNDESC AS "FLOWRULEPTRNDESC"
		FROM $schemaId$.TSEAIBR04
        WHERE BjobBzwkPrcssDstcd = #bjobBzwkPrcssDstcd#
	</statement>  
	
	<statement id="stageList" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
		SELECT 
		    BJOBBZWKPRCSSDSTCD  AS "BJOBBZWKPRCSSDSTCD" ,
		    BJOBSTGESERNO AS "BJOBSTGESERNO" ,
		    TRIM(BJOBSTGEDSTCD)	AS "BJOBSTGEDSTCD" ,
		    BJOBSTGEPTRNNAME AS "BJOBSTGEPTRNNAME" ,
			BJOBSTGEFLXBLCNDNDESC AS "BJOBSTGEFLXBLCNDNDESC",
			TELGMPTRNDSTCD AS "TELGMPTRNDSTCD" ,
			TELGMDTALSOPERCD AS "TELGMDTALSOPERCD"      ,
			BJOBCMNTELGMTRANCD AS "BJOBCMNTELGMTRANCD"   ,
			TOUTVAL AS "TOUTVAL" ,
			BJOBITERNOTMS AS "BJOBITERNOTMS" ,
			CNDNITEMDCSNCTNT AS "CNDNITEMDCSNCTNT" ,
			TRANPRCSSPRITY AS "TRANPRCSSPRITY" ,
			TELGMCLSID AS "TELGMCLSID" ,
			CNDNTELGMPTRNCD AS "CNDNTELGMPTRNCD",
			CNDNTELGMMGTCD AS "CNDNTELGMMGTCD" ,
			CNDNTRANCLSFICD AS "CNDNTRANCLSFICD" ,
			CNDNRSPNSCD AS "CNDNRSPNSCD" ,
			TRIM(NEXTSTGEDSTCDNAME) AS	"NEXTSTGEDSTCDNAME"	
		FROM $schemaId$.TSEAIBR02
		WHERE BjobBzwkPrcssDstcd = #bjobBzwkPrcssDstcd#
		ORDER BY  BjobStgeSerno 
	</statement>
    
    <statement id="insert_br02" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
		INSERT INTO $schemaId$.TSEAIBR02 (
				BjobBzwkPrcssDstcd    ,
				BjobStgeSerno         ,
				BjobStgeDstcd         ,
				NextStgeDstcdName     ,
				BjobStgePtrnName      ,
				TelgmPtrnDstcd        ,
				TelgmDtalsOperCd      ,
				BjobCmnTelgmTranCd    ,
				ToutVal               ,
				BjobIterNotms         ,
				TelgmClsID            ,
				CndnItemDcsnCtnt      ,
				CndnTelgmPtrnCd       ,
				CndnTelgmMgtCd        ,
				CndnTranClsfiCd       ,
				CndnRspnsCd           ,
				BjobStgeFlxblCndnDesc ,
				TranPrcssPrity        )
		VALUES (
				#bjobBzwkPrcssDstcd#    ,
				#bjobStgeSerno#         ,
				#bjobStgeDstcd#         ,
				#nextStgeDstcdName#     ,
				#bjobStgePtrnName#      ,
				#telgmPtrnDstcd#        ,
				#telgmDtalsOperCd#      ,
				#bjobCmnTelgmTranCd#    ,
            	#toutVal#               ,
            	#bjobIterNotms#         ,
				#telgmClsID#            ,
				#cndnItemDcsnCtnt#      ,
				#cndnTelgmPtrnCd#       ,
				#cndnTelgmMgtCd#        ,
				#cndnTranClsfiCd#       ,
				#cndnRspnsCd#           ,
				#bjobStgeFlxblCndnDesc# ,
            	#tranPrcssPrity#      )
	</statement>
    
    <statement id="insert_br04" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
		INSERT INTO $schemaId$.TSEAIBR04 (
				BjobBzwkPrcssDstcd    ,
				FlowRulePtrnDesc        )
		VALUES (
				#bjobBzwkPrcssDstcd#    ,
				#flowRulePtrnDesc#		)
	</statement>
	
    <statement id="delete_br02" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
		DELETE 	FROM $schemaId$.TSEAIBR02
        WHERE BjobBzwkPrcssDstcd = #bjobBzwkPrcssDstcd#
	</statement>
    
    <statement id="delete_br04" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
		DELETE 	FROM $schemaId$.TSEAIBR04
        WHERE BjobBzwkPrcssDstcd = #bjobBzwkPrcssDstcd#
	</statement>
		
	<statement id="update" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
		UPDATE $schemaId$.TSEAIBR04 
		SET FlowRulePtrnDesc = #flowRulePtrnDesc#
		WHERE BjobBzwkPrcssDstcd = #bjobBzwkPrcssDstcd#  
	</statement>
	
    <statement id="checkCount" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
        SELECT COUNT(BjobBzwkPrcssDstcd) 
        FROM   $schemaId$.TSEAIBR04
        WHERE BjobBzwkPrcssDstcd = #bjobBzwkPrcssDstcd#
    </statement>
        
	<statement id="getBjobStgeDstcd" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
         SELECT TRIM(BJOBSTGEDSTCD) AS "BJOBSTGEDSTCD",
                 CASE WHEN TRIM(BJOBSTGEDSTCD) = 'START' THEN ' '
                      WHEN TRIM(BJOBSTGEDSTCD) = 'END'   THEN 'ZZZZ1'
                      WHEN TRIM(BJOBSTGEDSTCD) = 'EEND'  THEN 'ZZZZ2'
                 ELSE BJOBSTGEDSTCD END AS "SORTORDER"
         FROM $schemaId$.TSEAIBR03
         WHERE BjobBzwkPrcssDstcd = #bjobBzwkPrcssDstcd#
         ORDER BY SORTORDER
	</statement>
    
</sqlMap>