Oracle dynamically inserts data and returns the inserted id

    <insert id="saveOrder">
        <selectKey keyProperty="order.id" order="AFTER" resultType="java.lang.Integer">
            select SEQ.CURRVAL as id from dual
        </selectKey>
        insert into
        <include refid="Table_Name"/>
        <trim prefix="(" suffix=")" suffixOverrides=",">
            ord.id,
            <if test="order.amount !=null">ord.amount,</if>
        </trim>
        <trim prefix="values(" suffix=")" suffixOverrides=",">
            <include refid="SEQ"/>,
            <if test="order.amount !=null">#{order.amount},</if>
        </trim>
    </insert>

Guess you like

Origin blog.csdn.net/weirdo_world/article/details/121400236