Return value of forech statement in mybatis

29 views Asked by At

As follows, I wrote a query to update multiple rows using the foreach statement.

    <update id="deleteVhcleInfos" parameterType="java.util.List">
        <foreach collection="list" item="item" index="index" separator=";" open="DECLARE BEGIN" close="; END;">
        UPDATE TB_VHCL_MANAGE
        <set>
            <if test='item.vhclno != null and item.vhclno != ""'>
                , DEL_YN = 'Y'
            </if>
            <if test='item.mdfcUserno != null and item.mdfcUserno != ""'>
                , MDFC_USERNO = ${item.mdfcUserno}
                , MDFC_DTTM = SYSDATE
            </if>            
        </set>
        <where>
            <if test='item.vhclno != null and item.vhclno != ""'>
                AND VHCLNO = #{item.vhclno}
            </if>
        </where>
        </foreach>
    </update>

I knew that in this case, the execution result of the first query (1 for success and 0 for failure) is returned. But for my query, -1 was returned even though the query was executed successfully. Why is this happening?

I have now written the code to return a failure message if the return value is less than 1. If returning -1 is a normal behavior, how should I handle it?

0

There are 0 answers