oracle超过1000条in报错怎么处理
这里的keys是一个List<String> 的集合
着重提示下这个or要用()包起来,很容易忽视的一个问题
select a
from activityorders where ent_id = 0 and event_type_code='8'
<if test="keys != null and keys.size > 0">
<!-- 这里的(很重要,很容易被忽视 -->
AND (ph_key IN
<!-- 处理in的集合超过1000条时Oracle不支持的情况 -->
<trim suffixOverrides=" OR ph_key IN()"> <!-- 表示删除最后一个条件 -->
<foreach collection="keys" item="item" index="index" open="(" close=")">
<if test="index != 0">
<choose>
<when test="index % 1000 == 9">) OR ph_key IN (</when>
<otherwise>,</otherwise>
</choose>
</if>
#{item}
</foreach>
</trim>)
</if>
group by market,ph_key