Why doesn't $P!{} works correctly on JasperServer?

In Jasper Studio, i created new Jasper Report with SQL srcript 
```
select * from
(
SELECT 1 v from dual union all 
SELECT 5 v from dual union all 
SELECT 4 v from dual union all
SELECT 2 v from dual union all
SELECT 3 v from dual
) da
$P!{P_C}

```
there are two Parameters:
```
    <parameter name="P_P" class="java.lang.Boolean"/>
    <parameter name="P_C" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA[IF($P{P_P},"where da.v =1","")]]></defaultValueExpression>
    </parameter>

```
When i run this report in Jasper Studio then everything is works fine and result is as expected:
```
_________
TEST REP|
________|
V       |
________|
1       |
2       |
3       |
4       |
5       |
```
But on JasperServer i get an error:
```
There was an error on the server. Try again or contact site administrators. (Error UID: 16864f27-a17a-43d1-8ed6-4386b52f57a0)
```
If i delete `$P!{P_C}` from SQL script, every thing works fine.

Version of TIBCO Jaspersoft® Studio is 6.9.0 

Version of Jasper Server is 7.2.0

If there is anybody who has the same thing?
 

alexshtanin's picture
Joined: Dec 19 2018 - 12:59am
Last seen: 3 years 7 months ago

3 Answers:

What are you feeding into the P_C string?

If it's a long string value make sure to add the ! as $P!

such as if you were feeding in an order by clause.

order by $P!{P_C}

 

 

danoldenkamp@gmail.com's picture
Joined: Aug 29 2018 - 11:12am
Last seen: 2 years 5 months ago

P_C is my WHERE clause

As you can see i've used ! in my SQL with parametr $P!{P_C}. 

The value of  P_C parametr is set to where da.v =1 when P_P parametr is true and "" when P_P parametr is false

I want to remove(or modify) WHERE clause in SQL depending on whether the parameter P_P is set or not.

alexshtanin's picture
Joined: Dec 19 2018 - 12:59am
Last seen: 3 years 7 months ago

 

Such as:

 where 
(da.v =1 and $P{P_P} = 'true')
or
(da.v like "" and ${P_P} = 'false')

 

In my limited experience I have only been able to feed parameter arrays as strings into SQL if it is within a clause followed by the clause name.

where $P!{example}

order by $P!{example}

group by $P!{example}

having $P!{example}

danoldenkamp@gmail.com's picture
Joined: Aug 29 2018 - 11:12am
Last seen: 2 years 5 months ago
Feedback