日期:2014-05-17  浏览次数:20717 次

急求:请各位仁兄帮帮看看这个SQL怎么回事?在Ibatis里始终没法通过,而在PL/SQL中单独执行完全没有问题。
<select id="getPostList"  parameterClass="String" resultClass="departmentInfo">
<![CDATA[select s.fstrPostId fstrPostId,s.fstrPostName fstrPostName,s.fstrDepartmentId fstrDepartmentId,s.fstrDepartmentName fstrDepartmentName,r.fint_state fintState
from(select p.fstr_postid fstrPostId,p.fstr_name fstrPostName,d.fstr_departmentid fstrDepartmentId,d.fstr_name fstrDepartmentName
from tbl_department d, tbl_group g, tbl_district t, tbl_post p
  where d.fstr_departmentid = g.fstr_departmentid
             and t.fstr_groupid = g.fstr_groupid
          and p.fstr_districtid = t.fstr_districtid
          )s,rt_policedutystate r
          where s.fstrPostId=r.fstr_postid(+)]]>
<dynamic>
<isNotEmpty property="value" prepend="and">
<![CDATA[s.fstrDepartmentId=#value#]]>
</isNotEmpty>
</dynamic>
<![CDATA[order by s.fstrPostId]]>
</select>

这个带嵌套子查询的SQL在PL/SQL中可以执行,完全没有问题,但是到了Ibatis里,怎么就出问题了,反复检查了很多次,始终没能找到解决方案,是不是Ibatis不支持嵌套子查询,不应该啊!
还请各位Ibatis高人指点一下,到底是哪儿出错了。谢谢!
------解决方案--------------------
报错提示是什么,这么乱没提示不好看
------解决方案--------------------
spring 能够打印出sql语句的吧。  你把完整的输出语句 放入到客户端查询一下看看是不是正确的。
------解决方案--------------------
肉眼,很难找这种错误,我经常用logger来打印Ibatis的sql,把控制台的sql 拷贝到你plsql执行一下就Ok 了
------解决方案--------------------
有必要写这么多![CDATA[]吗
------解决方案--------------------
这样改一下试试
select s.fstrPostId         fstrPostId,
       s.fstrPostName       fstrPostName,
       s.fstrDepartmentId   fstrDepartmentId,
       s.fstrDepartmentName fstrDepartmentName,
       --r.fint_state         fintState
       (select fint_state from rt_policedutystate where fstr_postid=s.fstrPostId)
  from (select p.fstr_postid       fstrPostId,
               p.fstr_name         fstrPostName,
               d.fstr_departmentid fstrDepartmentId,
               d.fstr_name         fstrDepartmentName
          from tbl_department d, tbl_group g, tbl_district t, tbl_post p
         where d.fstr_departmentid = g.fstr_departmentid
           and t.fstr_groupid = g.fstr_groupid
           and p.fstr_districtid = t.fstr_districtid) s/*,