<?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.hzs.scm.store.mapper.IcStoreHandSpecsMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hzs.common.domain.scm.store.IcStoreHandSpecs">
        <id column="PK_ID" property="pkId" />
        <result column="CREATION_TIME" property="creationTime" />
        <result column="MODIFIED_TIME" property="modifiedTime" />
        <result column="DEL_FLAG" property="delFlag" />
        <result column="PK_COUNTRY" property="pkCountry" />
        <result column="PK_CREATOR" property="pkCreator" />
        <result column="PK_MODIFIED" property="pkModified" />
        <result column="PK_ONHANDNUM" property="pkOnhandnum" />
        <result column="PK_SPECS_TYPE" property="pkSpecsType" />
        <result column="PK_SPECS" property="pkSpecs" />
        <result column="SPECS_NAME" property="specsName" />
    </resultMap>
    <update id="mergeIcOnHandSpecsByList">
        merge into IC_STORE_HAND_SPECS ip
        using (
        <foreach item="item" index="index" collection="icOnHandSpecsList" separator=" union ">
            select #{item.pkOnhandnum} pk_onhandnum,#{item.pkSpecsType} PK_SPECS_TYPE,#{item.pkSpecs} PK_SPECS,
            #{item.specsName, jdbcType=VARCHAR} specs_name,#{item.pkCountry} pk_country,#{item.pkCreator} pk_creator from dual
        </foreach>
        ) b
        on (ip.pk_onhandnum=b.pk_onhandnum and ip.pk_specs=b.pk_specs)
        WHEN NOT MATCHED THEN
        insert (PK_ID, PK_ONHANDNUM, PK_SPECS_TYPE, PK_SPECS, SPECS_NAME,PK_COUNTRY, PK_CREATOR)
        values (
        IC_ON_HAND_SPECS_SEQ.Nextval,b.pk_onhandnum,b.PK_SPECS_TYPE,b.PK_SPECS,
        b.SPECS_NAME,b.pk_country,b.pk_creator)
    </update>

</mapper>
