ibatis 与 sql 的问题

一个小问题:
Java持久层框架为ibatis;
表a在DB2数据库中,有一字段为name,现取出作为UserName,但是存在脏数据name为空格,现在想为空格是提示name为NODATA;
sql如下:

select case when REGEXP_LIKE(hex(trim(a.NAME)),'[0]{60}') then 'NODATA' else a.name end as UserName from  a  where  【condition】;

此sql在数据库中可以执行,但在Java代码中报错;
后分析原因为ibatis的问题,修改sql为下,以求到达同样的效果:

select 
case when REGEXP_LIKE(replace(a.NAME,' ',''),'[\u4e00-\u9fa5_a-zA-Z0-9]+') then trim(a.NAME)  else 'NODATA' end AS ParticipantName from a  where  【condition】,
posted @ 2018-04-02 11:18  XueXueLai  阅读(129)  评论(0编辑  收藏  举报