<?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.brilliance.isc.mda.dao.TejMapper">

    <resultMap id="BaseResultMap" type="com.brilliance.isc.common.rmbbop.entity.Tej">
        <result property="inr" column="inr" jdbcType="VARCHAR"/>
        <result property="ver" column="ver" jdbcType="VARCHAR"/>
        <result property="sta" column="sta" jdbcType="VARCHAR"/>
        <result property="objtyp" column="objtyp" jdbcType="VARCHAR"/>
        <result property="objinr" column="objinr" jdbcType="VARCHAR"/>
        <result property="listopertype" column="listopertype" jdbcType="VARCHAR"/>
        <result property="csta" column="csta" jdbcType="VARCHAR"/>
        <result property="seqno" column="seqno" jdbcType="VARCHAR"/>
        <result property="exchangedate" column="exchangedate" jdbcType="DATE"/>
        <result property="exchangeamt" column="exchangeamt" jdbcType="DECIMAL"/>
        <result property="exchangeenddate" column="exchangeenddate" jdbcType="DATE"/>
    </resultMap>

    <sql id="Base_Column_List">
        inr,ver,sta,objtyp,objinr,listopertype,csta,seqno,exchangedate,exchangeamt,exchangeenddate
    </sql>

    <select id="selectByPrimaryKey" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from tej
        where inr = #{inr,jdbcType=VARCHAR}
    </select>

    <delete id="deleteByPrimaryKey">
        delete from tej
        where inr = #{inr,jdbcType=VARCHAR}
    </delete>

    <insert id="insert">
        insert into tej (<include refid="Base_Column_List" />)
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            #{inr,jdbcType=VARCHAR},
            #{ver,jdbcType=VARCHAR},
            #{sta,jdbcType=VARCHAR},
            #{objtyp,jdbcType=VARCHAR},
            #{objinr,jdbcType=VARCHAR},
            #{listopertype,jdbcType=VARCHAR},
            #{csta,jdbcType=VARCHAR},
            #{seqno,jdbcType=VARCHAR},
            #{exchangedate,jdbcType=DATE},
            #{exchangeamt,jdbcType=DECIMAL},
            #{exchangeenddate,jdbcType=DATE},
        </trim>
    </insert>

    <insert id="insertSelective">
        insert into tej
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="inr != null">inr,</if>
            <if test="ver != null">ver,</if>
            <if test="sta != null">sta,</if>
            <if test="objtyp != null">objtyp,</if>
            <if test="objinr != null">objinr,</if>
            <if test="listopertype != null">listopertype,</if>
            <if test="csta != null">csta,</if>
            <if test="seqno != null">seqno,</if>
            <if test="exchangedate != null">exchangedate,</if>
            <if test="exchangeamt != null">exchangeamt,</if>
            <if test="exchangeenddate != null">exchangeenddate,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="inr != null">#{inr,jdbcType=VARCHAR},</if>
            <if test="ver != null">#{ver,jdbcType=VARCHAR},</if>
            <if test="sta != null">#{sta,jdbcType=VARCHAR},</if>
            <if test="objtyp != null">#{objtyp,jdbcType=VARCHAR},</if>
            <if test="objinr != null">#{objinr,jdbcType=VARCHAR},</if>
            <if test="listopertype != null">#{listopertype,jdbcType=VARCHAR},</if>
            <if test="csta != null">#{csta,jdbcType=VARCHAR},</if>
            <if test="seqno != null">#{seqno,jdbcType=VARCHAR},</if>
            <if test="exchangedate != null">#{exchangedate,jdbcType=DATE},</if>
            <if test="exchangeamt != null">#{exchangeamt,jdbcType=DECIMAL},</if>
            <if test="exchangeenddate != null">#{exchangeenddate,jdbcType=DATE},</if>
        </trim>
    </insert>

    <update id="updateByPrimaryKeySelective">
        update tej
        <set>
            <if test="ver != null">ver = #{ver,jdbcType=VARCHAR},</if>
            <if test="sta != null">sta = #{sta,jdbcType=VARCHAR},</if>
            <if test="objtyp != null">objtyp = #{objtyp,jdbcType=VARCHAR},</if>
            <if test="objinr != null">objinr = #{objinr,jdbcType=VARCHAR},</if>
            <if test="listopertype != null">listopertype = #{listopertype,jdbcType=VARCHAR},</if>
            <if test="csta != null">csta = #{csta,jdbcType=VARCHAR},</if>
            <if test="seqno != null">seqno = #{seqno,jdbcType=VARCHAR},</if>
            <if test="exchangedate != null">exchangedate = #{exchangedate,jdbcType=DATE},</if>
            <if test="exchangeamt != null">exchangeamt = #{exchangeamt,jdbcType=DECIMAL},</if>
            <if test="exchangeenddate != null">exchangeenddate = #{exchangeenddate,jdbcType=DATE},</if>
        </set>
        where inr = #{inr,jdbcType=VARCHAR}
    </update>

    <update id="updateByPrimaryKey">
        update tej
        <set>
            ver =  #{ver,jdbcType=VARCHAR},
            sta = #{sta,jdbcType=VARCHAR},
            objtyp = #{objtyp,jdbcType=VARCHAR},
            objinr = #{objinr,jdbcType=VARCHAR},
            listopertype = #{listopertype,jdbcType=VARCHAR},
            csta = #{csta,jdbcType=VARCHAR},
            seqno = #{seqno,jdbcType=VARCHAR},
            exchangedate = #{exchangedate,jdbcType=DATE},
            exchangeamt = #{exchangeamt,jdbcType=DECIMAL},
            exchangeenddate = #{exchangeenddate,jdbcType=DATE},
        </set>
        where inr = #{inr,jdbcType=VARCHAR}
    </update>

    <delete id="deleteByIds">
        delete from act where inr in
        <foreach item="item" index="index" collection="collection" open="(" separator="," close=")">
            #{item}
        </foreach>
    </delete>

    <update id="dyncUpdate">
        update tej
        <set>
            <if test="ver != null">ver = #{ver,jdbcType=VARCHAR},</if>
            <if test="sta != null">sta = #{sta,jdbcType=VARCHAR},</if>
            <if test="objtyp != null">objtyp = #{objtyp,jdbcType=VARCHAR},</if>
            <if test="objinr != null">objinr = #{objinr,jdbcType=VARCHAR},</if>
            <if test="listopertype != null">listopertype = #{listopertype,jdbcType=VARCHAR},</if>
            <if test="csta != null">csta = #{csta,jdbcType=VARCHAR},</if>
            <if test="seqno != null">seqno = #{seqno,jdbcType=VARCHAR},</if>
            <if test="exchangedate != null">exchangedate = #{exchangedate,jdbcType=DATE},</if>
            <if test="exchangeamt != null">exchangeamt = #{exchangeamt,jdbcType=DECIMAL},</if>
            <if test="exchangeenddate != null">exchangeenddate = #{exchangeenddate,jdbcType=DATE},</if>
        </set>
        ${conditions}
    </update>

    <delete id="dyncDelete">
        ${sql}
    </delete>

    <select id="dyncRead" resultMap="BaseResultMap">
        ${sql}
    </select>

    <select id="selectMaxSeqno" resultType="java.lang.Integer">
        SELECT MAX(SEQNO) FROM TEJ WHERE TRIM(OBJTYP)='TDN' AND TRIM(OBJINR)=#{inr}
    </select>

    <select id="selectByObjtypAndObjinr" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from tej
        where 1=1 and objinr = #{objinr,jdbcType=VARCHAR} and objtyp = #{objtyp,jdbcType=VARCHAR}
    </select>

    <delete id="deleteByobjtypAndobjinr">
        delete from tej
        where objtyp = #{objtyp,jdbcType=VARCHAR} and objinr = #{objinr,jdbcType=VARCHAR}
    </delete>


</mapper>