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

为什么ibatis 里面用case decode 都无法解析
select yp.id,yp.yhid,yh.xm,decode(yh.xb,'1','男','女') xb,yp.csdf,yh.yhbm,jl.nl,yp.msdf,yp.cscs,yp.mscs
from T_ZPGL_YP yp 
INNER join T_ZPGL_YH YH ON YP.YHID=YH.ID
INNER JOIN T_ZPGL_ZWGL ZW ON YP.ZWID=ZW.ID
INNER JOIN T_ZPGL_JL JL ON YH.ID=JL.YHID
INNER JOIN T_ZPGL_ZWRYQX QX ON QX.ZWID=ZW.ID

------解决方案--------------------
XML code
<select id="selectFunctionBySelfLink" resultType="function" parameterType="java.util.Map">
        SELECT DISTINCT
        A.functionID,A.name,A.functionNo,A.url,A.moreUrl,A.newWindow,A.orderID,A.layer,A.parentID,
        case when B.functionID is not null then 1 else 0 end hasChild, A.isMenu,A.swingMenu,A.requestAuth,A.permitIP,A.note,A.icon, A.bigIcon
        FROM
        (SELECT * FROM Sys_Function WHERE functionID in(SELECT functionID FROM Sys_RoleFunc WHERE roleid=#{roleID:INTEGER} ) AND isMenu=1 AND parentID=#{parentID:INTEGER} ) A,
        (SELECT * FROM Sys_Function WHERE functionID in(SELECT functionID FROM Sys_RoleFunc WHERE roleid=#{roleID:INTEGER} ) AND isMenu=1 ) B
        WHERE A.Functionid = B.parentID(+)
        <if test="orderByClause != null">order by ${orderByClause}</if>     </select>