传递参数时如何转义报表查询中生成的引号

时间:2012-09-07 11:12:45

标签: sql jasper-reports

我遇到了 JasperReports 的情况。我有一个报告查询,它有三个参数,就像这样:

SELECT DISTINCT
mr.int_grp_no,
mr.grp_no,
ISNULL((select cv_lbl from code_value_mcg where cv_type = 'mem grp type' and cv_code = (select grp_type from mem_group_mcg where group_id = mr.grp_no)), '') as grouptype,
isnull((select reg_date_en from mem_group_mcg where group_id = mr.grp_no), '') as reg_date,
isnull((select name from mem_group_mcg where group_id = mr.int_grp_no), '') as intergroup,
isnull((select name from mem_group_mcg where group_id = mr.grp_no), '') as groupname,
(select count(mid) from mem_reg_mcg where gender = 1 and grp_no = mr.grp_no) as totmale,
(select count(mid) from mem_reg_mcg where gender = 2 and grp_no = mr.grp_no) as totfemale,
((select count(mid) from mem_reg_mcg where gender = 1 and grp_no = mr.grp_no)+(select count(mid) from mem_reg_mcg where gender = 2 and grp_no = mr.grp_no))as total
FROM
dbo.mem_reg_mcg as mr
where $P{condition} and mr.reg_date between $P{Reg_date_from} and $P{Reg_date_to}]

在参数条件中,我会传递类似 mr.mem_in = 2 mr.grp_no = 3 的内容,但是当我在报告中传递参数时获取参数生成参数 'mr.mem_in = 2 and mr.grp_no = 3' 。引号是此查询中的错误。所以我假设摆脱了引号。

那我该怎么做呢?

任何想法都对我很有帮助。

0 个答案:

没有答案