<?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="UC0001">

    <!-- ジョブ前処理  -->
    <select id="getUnyohiduke" resultClass="java.util.Date">
        SELECT UNYOHIDUKE FROM UNYOHIDUKETABLE
    </select>

    <!-- 対象データ取得処理 -->
    <select id="getNyukinData" resultClass="jp.terasoluna.batch.tutorial.uc0001.JB0001Data">
        SELECT ID, SITEN, KOKYAKUID, NYUKIN, TORIHIKIBI FROM NYUKINTABLE ORDER BY ID
    </select>

    <!-- 対象データ取得処理（ジョブ分割） -->
    <select id="getPartitionNyukinData" parameterClass="jp.terasoluna.batch.tutorial.uc0001.JB0001JobContext"
        resultClass="jp.terasoluna.batch.tutorial.uc0001.JB0001Data">
        SELECT ID, SITEN, KOKYAKUID, NYUKIN, TORIHIKIBI FROM NYUKINTABLE WHERE SITEN = #partitionKey# ORDER BY ID
    </select>
    
    <!-- ビジネスロジック -->
    <select id="getZandakaData" parameterClass="java.lang.String" 
        resultClass="jp.terasoluna.batch.tutorial.uc0001.jb0001.ZandakaData">
        SELECT ZANDAKA FROM ZANDAKATABLE WHERE KOKYAKUID = #value#
    </select>
    <update id="updateZandakaData" parameterClass="jp.terasoluna.batch.tutorial.uc0001.jb0001.ZandakaData">
        UPDATE ZANDAKATABLE SET ZANDAKA = #zandaka#, SAISYUTORIHIKIBI = #saisyutorihikibi# WHERE KOKYAKUID = #kokyakuid#
    </update>
    <insert id="insertZandakaData" parameterClass="jp.terasoluna.batch.tutorial.uc0001.jb0001.ZandakaData">
        INSERT INTO ZANDAKATABLE(KOKYAKUID, ZANDAKA, SAISYUTORIHIKIBI) VALUES (#kokyakuid#, #zandaka#, #saisyutorihikibi#)
    </insert>

    <!-- ジョブ後処理  -->
    <insert id="insertZandakaRireki" parameterClass="jp.terasoluna.batch.tutorial.uc0001.jb0001.ZandakaRirekiData">
        INSERT INTO ZANDAKARIREKITABLE(SYORIBI, SYORIKENSU) VALUES (#syoribi#, #syorikensu#)
    </insert>
    
</sqlMap>
