Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Report Parameters in IN() clause
Priya R
<p>Hi,</p>
<p> </p>
<p>I'm using a "Text Box" for report parameter "PublicID" where user enter comma separated string values like 100005678,100006789,100007890, 100008765.</p>
<p> </p>
<p>How do I add single quotes around each comma separated string like below. Tried using string.split(,) and stored in arraylist and adding quotes around them but getting "Cannot find default value for object" error.</p>
<p> </p>
<p>I need to use "where public_id IN ( '100005678','100006789','100007890','100008765') " in my query.</p>
<p>Any help is much appreciated!!</p>
<p> </p>
<p>Cheers,</p>
<p>Priya</p>
Find more posts tagged with
Comments
Matthew L.
<p>This can be accomplished by adding a script in the "beforeOpen" script of the data set.</p>
<p> </p>
<p>Set your query as follows:</p>
<pre class="_prettyXprint _lang-sql">
where public_id IN ( '%SeeBeforeOpenScript%' )
</pre>
<p>Then use the following script in the data set's beforeOpen script:</p>
<pre class="_prettyXprint _lang-js">
this.queryText = this.queryText.replaceAll('%SeeBeforeOpenScript%',params["MyTextBoxParameter"].value.join("','" )); //String, add single quotes to the join method
</pre>
<p>For an example, see the following:</p>
<p><a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/36152-filters-not-adequate-for-large-data-what-then/?p=133966'>http://developer.actuate.com/community/forum/index.php?/topic/36152-filters-not-adequate-for-large-data-what-then/?p=133966</a></p>
;
Priya R
<p>Hi,</p>
<p> </p>
<p>Thanks for your reply. Still it is not working for me.</p>
<p>The example link you provided contains sample report that I'm not able to view or download. I'm getting "Sorry you don't have permission" error.</p>
<p> </p>
<p>Cheers,</p>
<p>Priya</p>
Priya R
<p>Hi Matthew,</p>
<p> </p>
<p>Join() will work only for multiselect parameters rite? I'm using a normal textbox where user enter comma separated values.</p>
<p>How do I use the values in IN (' ', ' ') query?</p>
<p> </p>
<p>Thanks,</p>
<p>Priya</p>
Matthew L.
<p>Priya,</p>
<p> </p>
<p>You are correct that the Join() method previously posted is for a multi-select parameter.</p>
<p>Please try the following script in the Data Set's beforeOpen method to see if this corrects the behavior for you on a text box string:</p>
<pre class="_prettyXprint _lang-js">
this.queryText = this.queryText.replaceAll('%SeeBeforeOpenScript%',params["MyTextBoxParameter"].value.replace(/\,/g, "'\,'"));
</pre>
Priya R
<p>Hi Matthew,</p>
<p> </p>
<p>No luck.. "Cannot find default value for object" is the exception I'm getting.</p>
<p> </p>
<p>Thanks,</p>
<p>Priya</p>
Matthew L.
<p>Can you post a simplified version of your design that replicates the issue so that I can look it over?</p>
Priya R
<p>Hi Matthew,</p>
<p> </p>
<p>Please find attached a sample report.</p>
<p> </p>
<p>Thanks,</p>
<p>Priya</p>
Matthew L.
<p>Priya,</p>
<p> </p>
<p>I believe the issue you were seeing had to do with one of the importPackage lines (they are not needed though).</p>
<p>Using this modified code, your example worked without an issue:</p>
<pre class="_prettyXprint _lang-js">
//importPackage(Packages.java.io);
//importPackage(Packages.java.lang);
//importPackage(Packages.java.util);
//importPackage(Packages.java.text);
if((params['City'].value != null) && (params['City'].value != ""))
{
var paramCity = params['City'].value.replace(/\,/g, "'\,'");
//System.out.println(paramCity);
this.queryText = this.queryText + " WHERE CLASSICMODELS.CUSTOMERS.CITY IN ('" + paramCity + "') "
java.lang.System.out.println("Console Out: " + this.queryText);
}
</pre>
Priya R
<p>Hi Matthew,</p>
<p> </p>
<p>Perfect!!! Working Fine now.. I wonder why the importPackage is giving this exception in the latest version of BIRT.</p>
<p>I have used this kind of console output method for older versions of BIRT and I never faced this issue.</p>
<p> </p>
<p>Anyway, Thank you very much Matthew!!! Much appreciated.</p>
<p> </p>
<p>Cheers,</p>
<p>Priya</p>