IN and NOTIN Clauses with $X{...}

0

The clause is used to check whether a particular value is present in a discrete set of values. Here is an example:

SELECT * FROM ORDERS WHERE SHIPCOUNTRY IS IN ('USA','Italy','Germany')

The set here is defined by the countries USA, Italy and Germany. Assuming we are passing the set of countries in a list (or better a java.util.Collection) or in an array, the syntax to make the previous query dynamic in reference to the set of countries is:

SELECT * FROM ORDERS WHERE $X{IN, SHIPCOUNTRY, myCountries}

where myCountries is the name of the parameter that contains the set of country names. The $X{} clause recognizes three parameters:

Type of function to apply (IN or NOTIN)

Field name to be evaluated

Parameter name

Above example works perfectly...

My questions is?

how to dynamically change Field name by passing parameter?

i have tried by passing parameter for field name $P{...} but couldn't

 

imrohithsnair's picture
Joined: Jan 30 2019 - 11:45pm
Last seen: 19 hours 26 min ago

2 Answers:

1

Given the way the $X function works, there is no way to parameterize the column name.

You would have to either change the $X logic within JasperReports, or generate your own SQL expression with $P!{}

 

swood_1's picture
604
Joined: Nov 15 2012 - 10:47am
Last seen: 9 hours 43 min ago
0

tnq u :-)

imrohithsnair's picture
Joined: Jan 30 2019 - 11:45pm
Last seen: 19 hours 26 min ago
Feedback