pass several parameters in ireport

1

I have the following problem: I created in Java a selectcheckbox , where the person will select several objects; when I send to managed bean , I get these objects listed. Now I want to send as a parameter to ireport to generate a report with the information that was selected.

In the other methods I use the following:

Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("codigo", agencias.getId());

    JasperImpressao jp = new JasperImpressao();

    jp.imprimirRelatorioPdf(parameters, "agencia.jasper");

This "jp.printRelatorioPdf" does everything; if I use code it prints normal. So I thought: there in my sql of ireport , instead of using

WHERE agencias.'id' = $P{codigo}"

use

WHERE agencias.'id' IN $P{codigo}"

Then in this parameter "code" I would pass a string with the agencies id I want to print: it would be "where agencies in" 1,2,3 "

But this does not work, it gives syntax error.

How could I do this?

    
asked by anonymous 16.06.2017 / 20:33

2 answers

0

select * from customer where $X{IN,customer_role,roles}

    
19.06.2017 / 15:21
1

Check the type of variable $P{codigo} in jasper , to work with the value "1,2,3" inside it, it must be of String type.

And to work in SQL your query string must be:

SELECT * FROM agencias WHERE agencias.id IN (1,2,3)
    
16.06.2017 / 20:41