日期:2014-05-20  浏览次数:20829 次

在ibatis中使用oracle的sql语句,但是无法解析 case when ....end 语句
在ibatis中使用oracle的sql语句,但是无法解析 case when ....end 语句
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">

<sqlMap namespace="mapDataDay">
 <select id="showmapout" resultClass="java.util.HashMap">
 <![CDATA[
 select t.acct_month "acct_month",
  t.day_id "day_id",
  t.area_no "area_no",
  t3.mnemonic "mnemonic",
  t2.area_name "area_name",
  TO_CHAR(sum(t.pay_fee) / 10000,'FM999,999,999,990.0') "pay_fee",
  TO_CHAR(sum(t.pay_fee_hb) / 10000,'FM999,999,999,990.0') "pay_fee_hb",
  TO_CHAR(sum(t.pay_fee - t.pay_fee_hb) / 10000,'FM999,999,999,990.0') "zz",
  case when sum(t.pay_fee_hb)=0 then to_char(100) else
  TO_CHAR((sum(t.pay_fee - t.pay_fee_hb) / sum(t.pay_fee_hb)) * 100,
  'FM999,999,999,990.0') end "zz_bfb",
  '万元' "kpi_dw"
  from dm.dm_sett_call_portal_d t,
  dim.dim_area_code t2,
  dim.dim_area_mnemonic t3
 where t.acct_month = 201102
  and t.day_id = 01

  and t.area_no = t2.area_code
  and t2.area_code = t3.area_no
  and t.pay_type in ('02', '05')
  and t.agent_no not like '0202%'
 group by t.area_no, t.acct_month, t2.area_name, t3.mnemonic,t.day_id,t.pay_fee_hb
 order by sum(t.pay_fee - t.pay_fee_hb)

 ]]>
 </select>

------解决方案--------------------
case when sum(t.pay_fee_hb)=0 then to_char(100) else
TO_CHAR((sum(t.pay_fee - t.pay_fee_hb) / sum(t.pay_fee_hb)) * 100,
'FM999,999,999,990.0') end case "zz_bfb",

------解决方案--------------------
楼主的写法没有问题对着哩
select case when to_char(sysdate,'yyyy-mm-dd')='2011-05-03' then to_char(100) 
else to_char(99999,'FM999,999,999,990.0') end "test",sysdate from dual
我试了下都是有输出的,你确定问题是出在这么,你没传参数,直接把这条SQL语句放在PL/SQL上执行下看看,是否有结果。。。。。IBATIS里面出现ORACLE特有的语法也可以正常解析的
------解决方案--------------------
已经作答:
http://topic.csdn.net/u/20110503/14/41e992d1-a5b7-473b-ad78-0b64b33a9662.html?seed=2046589597&r=74221628#r_74221628
------解决方案--------------------
楼主可否把错误提示贴出来啊 看你的语句木有错误啊