0
我在ibatis中使用下面的查詢遍歷列表。我想添加一個條件,因爲列表是空的。在這種情況下,我想改變condition.PFB查詢以xml:有條件地查詢迭代使用ibatis列表
<statement id="getSearchLateJob" parameterClass="map" resultMap="getCurrentJob_r">
select a.JOBSET as "JOBSET",
a.JOB as "JOB",
a.JOB_NO as "JOB_NO",
a.QUALIFIER as "QUALIFIER",
case when year(a.START_TIME) = 1900 then null else a.START_TIME end as "EXPECTED_START_TIME",
case when year(a.END_TIME) = 1900 then null else a.END_TIME end as "END_TIME",
datediff(mi,a.START_TIME,a.END_TIME) as "DURATION",
b.JOB_AVG as "JOB_AVG",
a.STATUS as "STATUS"
from CA_JOB_STATUS a,JOB_AVG b
where a.JOBSET = b.JOBSET
and a.JOB=b.JOB
and a.JOBSET like #jobSet:VARCHAR#
and a.JOB like #job:VARCHAR#
<!-- and a.STATUS in -->
<dynamic prepend="and a.STATUS in ">
<iterate property= "currentJobStatusArr" open="(" close=")" conjunction=",">
#currentJobStatusArr[]:VARCHAR#
</iterate>
</dynamic>
order by a.END_TIME desc, a.START_TIME desc
在這種情況下,我怎麼能動態改變前置它遍歷一個列表,並建立IN詢問,到類似的查詢:事情是這樣的:
變化來自:
select * from table where status in (?,?)
要:
select * from table where status like ?