在mybatis里面写plsql即可

<insert id="insertSpecialKeyword" parameterType="map">
        begin
            delete from STOCK_LIVE_SPECIAL_KEYWORD where special_id=#{map.specialId};
            <foreach collection="map.list" item="emp" separator=";">
                insert into STOCK_LIVE_SPECIAL_KEYWORD(special_id,keyword)VALUES(#{map.specialId},#{emp})
            </foreach>
        ;end;
 </insert>

注意:数据库有时会限制执行多条sql:
在连接url后加上&allowMultiQueries=true即可

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐