Dynamically Passing Parameters to iReport 4.0.1

2019-09-02 03:42发布

问题:

I'm working on iReport version 4.0.1. My query is

select productcategory as CATEGORYNAME,
    value as VALUE,m_product_id::text,
    product as NAME,count(pricexception) as stock 
from dtawm_stockcalculation_v
where m_product_id=$P{M_Product_ID} or $P{M_Product_ID} is null
    and productcategory=$P{M_Product_Category_ID} 
    or $P{M_Product_Category_ID} is null
group by value,m_product_id,product,productcategory 

In which I am using two parameters: $P{M_Product_ID} and $P{M_Product_Category_ID}. Here I am setting default value for both parameters as '%' but I get an error:

Cannot cast char to string.

回答1:

Usually we use " " to set the default value for string type parameter.