NutzCN Logo
问答 一个参数传两次,占位符名称相同,参数要怎么设呢?
发布于 2720天前 作者 西风微凉 1839 次浏览 复制 上一个帖子 下一个帖子
标签:

一个参数传两次,占位符名称相同,参数要怎么设呢?

Sql sql = Sqls.create("select IFNULL(MAX(x.id)+1,@placeId*1000+1) from tm_term x where x.id like '@placeId%' ");
sql.params().set("placeId", placeId).set("placeId", placeId);

org.nutz.dao.DaoException: !Nutz SQL Error: 'select IFNULL(MAX(x.id)+1,350104000001*1000+1) from tm_term x where x.id like '350104000001%''
PreparedStatement: 
'select IFNULL(MAX(x.id)+1,?*1000+1) from tm_term x where x.id like '?%''
CaseMessage=Parameter index out of range (2 > number of parameters, which is 1).
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:104)
	at org.nutz.plugins.cache.dao.CachedNutDaoExecutor._exec(CachedNutDaoExecutor.java:317)
	at org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:187)
2 回复

如果那是数字, 用$吧

添加回复
请先登陆
回到顶部