<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.its.vms.dao.mapper.RseObuClctMapper">

    <insert id="insertRseObuClctHs" parameterType="com.its.vms.entity.TbRseObuClct">
    <![CDATA[
          INSERT INTO TB_RSE_OBU_CLCT_HS (
                   RSE_CTLR_NMBR,
                   CLCT_DT,
                   OBU_IDNT_NMBR,
                   CTYP,
                   OBU_KIND )
          VALUES (
                  #{obj.RSE_CTLR_NMBR},
                  #{obj.CLCT_DT},
                  #{obj.OBU_IDNT_NMBR},
                  #{obj.CTYP},
                  #{obj.OBU_KIND}
                 )
    ]]>
    </insert>

    <update id="updateRseObuClctPnst" parameterType="com.its.vms.entity.TbRseObuClct">
    <![CDATA[
		MERGE INTO TB_RSE_OBU_CLCT_PNST L
        USING (SELECT #{obj.RSE_CTLR_NMBR} AS RSE_CTLR_NMBR,
                      #{obj.CLCT_DT}       AS CLCT_DT,
                      #{obj.OBU_IDNT_NMBR} AS OBU_IDNT_NMBR,
                      #{obj.CTYP}          AS CTYP,
                      #{obj.OBU_KIND}      AS OBU_KIND
                 FROM DUAL) M
                ON (L.RSE_CTLR_NMBR = M.RSE_CTLR_NMBR)
        WHEN MATCHED THEN
           UPDATE SET
                      L.CLCT_DT       = M.CLCT_DT,
                      L.OBU_IDNT_NMBR = M.OBU_IDNT_NMBR,
                      L.CTYP          = M.CTYP,
                      L.OBU_KIND      = M.OBU_KIND
        WHEN NOT MATCHED THEN
           INSERT (
                   RSE_CTLR_NMBR,
                   CLCT_DT,
                   OBU_IDNT_NMBR,
                   CTYP,
                   OBU_KIND )
           VALUES (
                   M.RSE_CTLR_NMBR,
                   M.CLCT_DT,
                   M.OBU_IDNT_NMBR,
                   M.CTYP,
                   M.OBU_KIND )
    ]]>
    </update>

</mapper>
