Jump to content
We've recently updated our Privacy Statement, available here ×

(urgent) multi value on "in operator of where cause"


hkjang

Recommended Posts

Hi

I have a question regarding the parameter that is put with "in operator" on SQL.
I like to use multi parameter, so I like to utilize "in operator" on SQL.
For example, SQL in ireport will be

"select emp_name from employee where emp_id = $P{emp_id}" (tried type: java.math.BigDecimal or java.lang.String)

I defined one parameter emp_id on ireport. (class type : java.lang.String)

When I run the report with single value like "111" it is run okey,
But if I run with multi value like "111, 222" I got error message as below

"ORA-01722: invalid number"

Would you please advice how could I avoid error message?
Any advice will be appreciated,

Thanks in advice,
HKJang
 

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

As far as I can understand, if you use "$P{param}" the parameter will be expanded according to its definition inside the SQL. For instance a string wille be expanded with the quotes ('string').

If you use $P!{param}, the parameter will be expanded as is.

Sorry, in my prvious post I did a mistake : the parameter, for having the correct SQL syntax, must include the parenthesis :

= "(111,222,333)"

I already used this formulation and it worked

Your suggestion seems OK but I didn't test it : but you have to use the $P! formulation as explained above :

" in ($P!{param})"

Link to comment
Share on other sites

There is also the $X syntax, which automatically manages IN clauses. This is part of JasperReports.

 

    <parameter name="collection" isForPrompting="true" class="java.util.Collection"/>
...

    <queryString><![CDATA[

SELECT columns...

FROM tables....

where $X{IN, column, collection}

</queryString>
 

This automatically generates the right IN clause.

 

 

Sherman

Jaspersoft

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...