无法从String转换为布尔值

时间:2016-06-24 06:19:36

标签: java jasper-reports

我有2个参数,哪个参数类是:java.lang.String用于: 查询 pSalesType enter image description here enter image description here

查询的默认表达式如下所示:

(new String("all").equals($P{pSales_type}) ? "SELECT SALESMAN, SALES_AMOUNT, SALES_TYPE FROM (SELECT T1.SYS_USERNAME AS SALESMAN, SUM(REQ_SALES_AMOUNT) AS SALES_AMOUNT, 'Requisition' AS SALES_TYPE FROM t_requisition LEFT JOIN t_system_user T1 ON T1.SYSUSER_ID = T_REQUISITION.ENTERED_BY WHERE REQ_SALES_AMOUNT IS NOT NULL AND REQ_PROC_STATUS = 'Approved'  UNION ALL SELECT T1.SYS_USERNAME AS SALESMAN, SUM(WRO_SALES_AMOUNT) AS SALES_AMOUNT, 'Work Order' AS SALES_TYPE FROM t_work_order LEFT JOIN t_system_user T1 ON T1.SYSUSER_ID = t_work_order.ENTERED_BY WHERE WRO_SALES_AMOUNT IS NOT NULL AND WRO_APPROVAL_STATUS = 'Y' ) xx GROUP BY SALESMAN, SALES_TYPE " :
(new String("rq").equals($P{pSales_type}) ? "SELECT T1.SYS_USERNAME AS SALESMAN, SUM(REQ_SALES_AMOUNT) AS SALES_AMOUNT, 'Requisition' AS SALES_TYPE FROM t_requisition LEFT JOIN t_system_user T1 ON T1.SYSUSER_ID = T_REQUISITION.ENTERED_BY WHERE REQ_SALES_AMOUNT IS NOT NULL AND REQ_PROC_STATUS = 'Approved'" :
(new String("wo").equals($P{pSales_type}) ? "SELECT T1.SYS_USERNAME AS SALESMAN, SUM(WRO_SALES_AMOUNT) AS SALES_AMOUNT, 'Work Order' AS SALES_TYPE FROM t_work_order LEFT JOIN t_system_user T1 ON T1.SYSUSER_ID = t_work_order.ENTERED_BY WHERE WRO_SALES_AMOUNT IS NOT NULL AND WRO_APPROVAL_STATUS = 'Y'" :
"SELECT T1.SYS_USERNAME AS SALESMAN, SUM(REQ_SALES_AMOUNT) AS SALES_AMOUNT, 'Requisition' AS SALES_TYPE FROM t_requisition LEFT JOIN t_system_user T1 ON T1.SYSUSER_ID = T_REQUISITION.ENTERED_BY WHERE REQ_SALES_AMOUNT IS NOT NULL AND REQ_PROC_STATUS = 'Approved'")))

在报告查询中,我这样说:

$P!{query}

enter image description here

它能够从数据库加载字段而不会出现任何错误。

SALESMAN
SALES_AMOUNT
SALES_TYPE

但是当我预览它时,它会给出错误:无法从String转换为布尔值 enter image description here

要解决的任何想法?

1 个答案:

答案 0 :(得分:0)

你需要将其他部分放在额外的paranthesis

(new String("all").equals($P{pSales_type}) ? "SELECT .... :
((new String("rq").equals($P{pSales_type}) ? "SELECT .... :
((new String("wo").equals($P{pSales_type}) ? "SELECT .....      ))