使用ibatis ,运行这段sql一直报错,ORA-00933,大家帮我看看是那的错误,谢谢
<selectid="queryPersonList"parameterClass="staff"resultClass="staff">select*fromtest<...
<select id="queryPersonList" parameterClass="staff" resultClass="staff">
select * from test
<dynamic prepend="where">
<isNotEmpty prepend="and" property="username">username=#username#</isNotEmpty>
<isNotEmpty prepend="and" property="password">password=#password#</isNotEmpty>
</dynamic>
</select>
运行上面代码一直 报错ORA-00933:
但是如果这样写就没错,
<select id="queryPersonList" parameterClass="staff" resultClass="staff">
select * from test where test.username=#username# and test.password=#password#
</select>
为什么呢?应该怎么改啊? 展开
select * from test
<dynamic prepend="where">
<isNotEmpty prepend="and" property="username">username=#username#</isNotEmpty>
<isNotEmpty prepend="and" property="password">password=#password#</isNotEmpty>
</dynamic>
</select>
运行上面代码一直 报错ORA-00933:
但是如果这样写就没错,
<select id="queryPersonList" parameterClass="staff" resultClass="staff">
select * from test where test.username=#username# and test.password=#password#
</select>
为什么呢?应该怎么改啊? 展开
展开全部
<isNotEmpty prepend="and" property="username">username=#username#</isNotEmpty>
把这里的prepend="and" 去掉 如果加上 username不为空的时候
sql是这样 select * from test where and test.username=#username# and test.password=#password# where 后多了and 所以执行报错
把这里的prepend="and" 去掉 如果加上 username不为空的时候
sql是这样 select * from test where and test.username=#username# and test.password=#password# where 后多了and 所以执行报错
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询