发新话题
打印

has语句的使用

has语句的使用

select b.TypeName,a.Name,a.Unit,a.Brand,a.Price,a.Number,a.Manufacturer from

aos_consumable_ConsumableAsset as a right join  aos_consumable_ConsumableType as b on

a.ConsumableTypeId = b.DirectoryID  where 1=1 and (a.BuyDate between ${buyDate}  and

${endTime} ) ${has(name)?(" and a.name like '%"+name+"%'"):""} ${has(typeName)?(" and

b.TypeName like '%"+typeName+"%'"):""} ${has(storeAddr)?(" and a.StoreAddr like

'%"+storeAddr+"%'"):""}

这条SQL语句对不?????
为什么查询出来总是没有数据???

TOP

如果1,可检查控制台看,有没有错误发生。
如果2,可以在 sqlreader.java中,加上一句调试Util.debug,如下所示
复制内容到剪贴板
代码:
      String sqlcopy = sql;

            if ((sql.indexOf("${") > -1)) {
                if (script instanceof ReportContext) {
                    sqlcopy = (String) ((ReportContext) script).evalTemplate(sql);
                } else {
                    if (context == null) {
                        context = ReportContext.getDefaultContext();
                    }

                    sqlcopy = (String) context.evalTemplate(sql);
                }
            }
            
            Util.debug(logger,sqlcopy);  // 合并后的sql输出到控制台

            conn = getConnection2(script);

            if (isQuery(sqlcopy)) {

TOP

发新话题