How to set default value of parameter input control in Ireport

I have a problem with my parameter who are an input control in Ireport. My parameter is a boolean. And I try to set a default value because I need to modify my sql request with parameter. By example if my parameter is true so I put on my request a like with an other parameters else I put nothing. But my problem is my parameters is always true or false and not the value I define in default value.

This is my try with default value of my parameter:

? " AND d.cellule like '%$P{mot_cle}%'"
: " "

And this my sql request:

     r.designation AS designation,
     l.nom AS nom,
     e.gare AS gare,
     b.intitule AS intitule,
     a.code_mire AS code_mire,
     af.codegmao AS codegmaoAF,
     ap.codegmao AS codegmaoAP,
     d.cellule AS repere,
     d.observation AS observation,
     m.appareil AS appareil
      armoireprincipale ap
LEFT JOIN armoire a ON a.idbranchement = ap.idbranchement
LEFT JOIN armoirefille af ON af.idbranchement = a.idbranchement
LEFT JOIN branchement b ON b.idbranchement = a.idbranchement
LEFT JOIN ligne l ON l.id_ligne = b.id_ligne
LEFT JOIN reseau r ON r.id_reseau = l.id_reseau
LEFT JOIN edifice e ON e.indic = b.indic
LEFT JOIN depart d ON d.idbranchement = a.idbranchement
LEFT JOIN materiel m ON m.id_materiel = d.id_materiel
WHERE  a.idbranchement IN (SELECT b.idbranchement
            FROM branchement b0
            LEFT JOIN cable c ON c.idbranchement = b0.idbranchement
            LEFT JOIN cable_depart cb ON =
            LEFT JOIN depart d0 ON d0.iddepart = cb.iddepart
            LEFT JOIN armoire a0 ON a0.idbranchement = d0.idbranchement
            LEFT JOIN armoireprincipale ap0 ON ap0.idbranchement = a0.idbranchement
            WHERE ap0.ug_pef= $P{id_pef}
) $P{choix_repere_depart};

So I need help to understand what is wrong on my report. If someone has an idea please help me!!! Thank!!

johann60280's picture
Joined: Dec 27 2016 - 1:24am
Last seen: 3 years 3 months ago

2 Answers:

JasperReports don't support nested parameters. Instead of nesting parts of a sql command, try setting the true and false condition each to an entire sql command and use $P!

hozawa's picture
Joined: Apr 24 2010 - 4:31pm
Last seen: 3 years 11 months ago

Have you an example to give me for my case ?

johann60280's picture
Joined: Dec 27 2016 - 1:24am
Last seen: 3 years 3 months ago