最近使用的finereport ,使用了神奇的传参功能。。。。。。
代码如下
select t.title,t.code,
Decode(t.status,0,'草稿',1,'已提交',2,'已批准',3,'已发布',4,'已提交',5,'已注销') as status
,u.username, --执行人
r.keycode as category, --类别
d.keycode as assettype, --资产类型
Decode(t.apply_type,'1','安全作业','2','符合性检查','3','事件管理') as apply_type,
t.version,t.standard,t.description
from smp_policy t,tb_user u,
(select * from tb_dictionary where type = 'assettype' ) d ,
(select * from tb_dictionary where type ='policy.type') r where t.op_id = u.id and d.value(+) = t.assettype and r.value = t.category
${if(len(code) == 0,"","and t.code like '%"+code+"%'")}
${if(len(title) == 0,"","and t.title like '%"+title+"%'")}
其中(+) 是一个表关联外面一个表的时候 如果该字段为空导致查询缺少数据的问题,
上面的查询中的assettype 就有可能为空,导致查询缺少数据
如图所示