数据库环境oracle11g
功能:模式查询 传入name
代码如下
Kv cond=new Kv(); if(getPara("name")!=null&&!"".equals(getPara("name"))) { cond.set("name",getPara("name")); } try { SqlPara sqlPara= Db.getSqlPara("school.find",Kv.by("cond",cond)); System.out.print(sqlPara.getSql()+" "+cond.getStr("name")); Page<Record> page= Db.paginate(pindex,size,sqlPara); result= returnResult(ReturnCode.Success200,""); result.setData(page); }catch (Exception e) { System.out.print(e); result= returnResult(ReturnCode.Error500,":"+e); }
school.find内容如下 #sql("find") select a.*,b.name as REGIONNAME from SZCP_SCHOOL a left join SZCP_REGION b on a.REGIONID=b.ID #for(x : cond) #(for.first ? "where": "and") #if(x.key=="name") a.name like '%#para(x.value)%' #else #(x.key) #para(x.value) #end #end order by a.ID desc #end
日志输出
select a.*,b.name as REGIONNAME from SZCP_SCHOOL a left join SZCP_REGION b on a.REGIONID=b.ID where a.name like '%?%' order by a.ID desc
name值 输出为 “而”
错误反馈
com.jfinal.plugin.activerecord.ActiveRecordException: java.sql.SQLException: 无效的列索引
帮忙看一下是不是我程序中语法导致错误还是sql语法导致的错误,sql语句在数据库中执行正常
项目:JFinal
显然你的程序生成了错误的 sql 与 para