<?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.th.demo.mapping.common.CommonMapper">
    <resultMap id="BaseResultMap" type="com.th.demo.model.common.Common">
        <id column="ID" jdbcType="VARCHAR" property="id"/>
    </resultMap>


    <resultMap type="java.util.HashMap" id="cursorMap">

    </resultMap>


    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from T_COMMON
    where ID = #{id,jdbcType=VARCHAR}
  </delete>
    <insert id="insert" parameterType="com.th.demo.model.common.Common">
    insert into T_COMMON (ID)
    values (#{id,jdbcType=VARCHAR})
  </insert>
    <insert id="insertSelective" parameterType="com.th.demo.model.common.Common">
        insert into T_COMMON
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                ID,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>


    <select id="selectPrimaryKey" resultType="java.lang.String">
 SELECT  REPLACE(UUID(),'-','') from dual
  </select>



    <select id="updateProc" statementType="CALLABLE" resultType="java.lang.String">
        {call ${procName}(
        <foreach item="item" index="index" collection="param"
                 open="" separator="," close="">
            #{item}
        </foreach>,
        #{results, jdbcType=VARCHAR, mode=OUT}
        )}
    </select>


    <select id="selectProcList" statementType="CALLABLE" >
        {call ${procName}(
        <foreach item="item" index="index" collection="param"
                 open="" separator="," close="">
            #{item}
        </foreach>,
        #{startRows, jdbcType=INTEGER ,mode=IN},
        #{endRows, jdbcType=INTEGER  ,mode=IN},
        #{results, jdbcType=CURSOR,resultMap=cursorMap ,mode=OUT}
        )}
    </select>


    <select id="selectProcRows" statementType="CALLABLE" >
        {call ${procName}(
        <foreach item="item" index="index" collection="param"
                 open="" separator="," close="">
            #{item}
        </foreach>,
        #{results,  jdbcType=VARCHAR, mode=OUT}
        )}
    </select>


    <select id="selectProc" statementType="CALLABLE" >
        {call ${procName}(

        <foreach item="item" index="index" collection="param"
                 open="" separator="," close="">
            #{item}
        </foreach>,
        #{results, jdbcType=CURSOR,resultMap=cursorMap ,mode=OUT}
        )}
    </select>
</mapper>