为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】:达梦8
【操作系统】:linux
【CPU】:飞腾麒麟10
【问题描述】:
mybatis中的concat函数,执行失败;
原生sql
select t.,
K.title,
K.app_id libraryId,
'atomic' appCode,
K.STATE,
K.publish_date publishDate,
K.directory_id directoryId,
K.VERSION from (
select
DISTINCT dh.app_id,
dh.file_id AS fileId,
f.file_name AS fileName,
dh.create_user_id AS createUserId,
dh.create_time AS operationTime,
dh.tenant_id AS tenantId,
dh.app_id AS id
from IKBASE.sys_download_history dh
JOIN IKBASE.sys_att_file f ON dh.file_id = f.ID
)t
JOIN ikbase.app_atomic_main K ON K.ID = t.app_id
where createUserId = #{param.userId}
and tenantId = #{param.tenantId}
AND state = 1
<if test="param.keyword != null and param.keyword!=''">
and title like concat(concat('%', #{param.keyword}), '%')
</if>
ORDER BY operationTime #{param.orderType}
报错信息:
语法分析出错
; bad SQL grammar []; nested exception is dm.jdbc.driver.DMException: -2007 第 27 行, 第 32 列[?]附近出现错误:
语法分析出错(String), 1699299174401544194(String), 1699299174383751168(String), 18912345678(String), 0(Integer), 设备类型:UNKNOWN,操作系统:Unknown,浏览器:Unknown,浏览器版本:null,浏览器引擎:OTHER(String)
可以开一下数据库的sql日志找到具体数据库执行sql。
使用sysdba登录数据库,执行sp_Set_para_value(1,'SVR_LOG',1);进行开启,
开启完成后,如果未修改sqllog.ini中的日志存放路径,默认在数据库软件 dmdbms/log目录下,以dmsql开头的日志。具体看下报错sql。
找到具体报错sql后,使用sysdba登录数据库,执行sp_Set_para_value(1,'SVR_LOG',0);关闭sql日志
concat函数是支持的。
根据现在提供的信息报错第27行 是order by 的地方,看你这个应该是两个列顺序排列,第二个传参进来的,两个列排序中间间需要加逗号。
concat应该是支持的。
and title like '%'|| #{param.keyword} ||'%'