Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Break one parameter into three pieces for query?
Eduardo Serrano
<p>I need to create a BIRT report with just one parameter. for example..</p>
<p> </p>
<p>111 HEB PRODUCE</p>
<p>112 HEB FROZEN</p>
<p>113 HEB SEASONAL</p>
<p> </p>
<p>This will be a list box I will create in the Report Parameters.</p>
<p> </p>
<p>the values will be the numbers</p>
<p> </p>
<p>so the parameter entered by the user will be 111, or, 112, or 113</p>
<p> </p>
<p>Then I want to break the parameter entered by the user in 3 piece, like 1, 1, 3</p>
<p> </p>
<p>and then use these three pieces in my query</p>
<p> </p>
<p>WHERE a.customerId = ? (1)</p>
<p>AND a.locationId = ? (1)</p>
<p>AND a.dockId = ? (3)</p>
<p> </p>
<p>Or any other solution to use only one parameter but check three fields in the query?</p>
<p> </p>
<p>Is this possible?</p>
<p> </p>
Find more posts tagged with
Comments
Matthew L.
<p>You can break up the value in the parameter by its characters using JavaScript and assign values to your query in the beforeOpen statement.</p>
<p> </p>
<p>Modify your query as so:</p>
<pre class="_prettyXprint _lang-sql">
WHERE a.customerId = %v1%
AND a.locationId = %v2%
AND a.dockId = %v3%
</pre>
<p style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">Then in the beforeOpen statement of your Data Set, use the following to replace the %v% values with a character from the parameter value:</p>
<div>
<pre class="_prettyXprint _lang-js">
this.queryText = this.queryText.replaceAll('%v1%',params["MyParameter"].value[0]); //First character
this.queryText = this.queryText.replaceAll('%v2%',params["MyParameter"].value[1]); //Second character
this.queryText = this.queryText.replaceAll('%v3%',params["MyParameter"].value[2]); //Third character
</pre>
</div>
<div>See attached example</div>
Eduardo Serrano
<p>Genius! Thank you very much Matthew L.</p>
<p> </p>
<p> </p>
<blockquote class="ipsBlockquote" data-author="Matthew L." data-cid="145504" data-time="1476107479">
<div>
<p> </p>
<p>You can break up the value in the parameter by its characters using JavaScript and assign values to your query in the beforeOpen statement.</p>
<p> </p>
<p>Modify your query as so:</p>
</div>
</blockquote>