Jump to content

Using $P!{} to add a parameter filter to select statement


janlandry

Recommended Posts

I have a string parameter called CompanyCode.  If CompanyCode has a value (notEmpty)  I want to add this line to my select statement.

AND BIlling.CompanyCode = ${CompanyCode}

 

I declared another parameter, CompanyCodeSql which has the default expression

$P{CompanyCode}.isEmpty() ? "" : " AND Billing.`Company_Code` = $P{CompanyCode} "

 

This works when CompanyCode is empty but I get a syntax error when CompanyCode has a value.  I guess the $P{CompanyCode} is not getting evaluated because it is in quotes? 

 

Any help appreciated.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi,

Try this. It might look the same as what you had but what you acually need to to is to concatenate the "AND Billing.Company_Code = " with the parameter $P{CompanyCode}.

You had the parameter inside the already existing string which will not yield the value of the parameter but instead the actual text $P{CompanyCode}.

Hope this helps.

 

 

Code:
$P{CompanyCode}.isEmpty() ? "" : "AND Billing.Company_Code = "+$P{CompanyCode} 
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...