weixin_42210345
维斯 ๑
2008-06-25 10:35
浏览 446
已采纳

ibatis sql语句 大于等于号的问题

刚接触IBATIS,希望大家能够帮忙看一下.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap

PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"

"http://ibatis.apache.org/dtd/sql-map-2.dtd">














select ltrim(substr(report_date,7,2),0) day,
min(starttime) starttime,
max(endtime) endtime,
case
when min(starttime)[color=red][b]<=[/b][/color]'12:00' and max(endtime)<='12:00'
then (to_date(max(endtime),'hh24:mi')-to_date(min(starttime),'hh24:mi'))*24
when (min(starttime)>='12:00' and min(starttime)<='13:00') and (max(endtime)>='12:00' and max(endtime)<='13:00')
then 0
when min(starttime)>='13:00' and max(endtime)>='13:00'
then (to_date(max(endtime),'hh24:mi')-to_date(min(starttime),'hh24:mi'))*24
when min(starttime)<='12:00' and (max(endtime)>='12:00' and max(endtime)<='13:00')
then (to_date('12:00','hh24:mi')-to_date(min(starttime),'hh24:mi'))*24
when min(starttime)<='12:00' and max(endtime)>='13:00'
then (to_date(max(endtime),'hh24:mi')-to_date(min(starttime),'hh24:mi'))*24-1
when (min(starttime)>='12:00' and min(starttime)<='13:00') and max(endtime)>='13:00'
then (to_date(max(endtime),'hh24:mi')-to_date('13:00','hh24:mi'))*24
end worktime,
report_date,substr(max(sys_connect_by_path(workcontent,',')),2) workcontent,
max(department) department,
max(team) team,
max(confirm) confirm
from (select dailyreport.*,row_number() over(partition by report_date order by workcontent) rn from dailyreport)
where login_id=#loginid# and substr(report_date,0,6)=#reportdate#
group by report_date
start with rn=1
connect by rn-1=prior rn and report_date=prior report_date

问题:
如粗体红色部分所示,IBATIS中这样写报错.在网上查了一下,除等于外一般用动态SQL这种写法
问题是我的写在CASE WHEN 语句中,应该怎么样修改....迷茫中...等待大好人....

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • lggegegmail
    lggegegmail 2008-06-25 11:21
    已采纳

    http://www.iteye.com/problems/624

    这个里面有答案.. 哈哈

    点赞 评论
  • congjl2002
    congjl2002 2008-06-25 11:25

    因为这个是xml格式的,所以不允许出现类似“>”这样的字符,但是都可以使用<![CDATA[ ]]>符号进行说明,将此类符号不进行解析
    你的可以写成这个:
    [code="java"]<![CDATA[ when min(starttime)<='12:00' and max(endtime)<='12:00' ]]> [/code]

    点赞 评论

相关推荐