Replacing condition in where clause dynamically
<p><span style="font-size:12px;"><span style="font-family:'trebuchet ms', helvetica, sans-serif;">Hi All,</span></span></p>
<p> </p>
<p><span style="font-size:12px;"><span style="font-family:'trebuchet ms', helvetica, sans-serif;">I am a beginner in BIRT trying to use Javascript to replace (using beforeOpen in script) a condition in the where clause of my query.</span></span></p>
<p> </p>
<p><span style="font-size:12px;"><span style="font-family:'trebuchet ms', helvetica, sans-serif;">Query looks like:</span></span></p>
<p> </p>
<p><span style="font-size:12px;"><span style="font-family:'trebuchet ms', helvetica, sans-serif;">select * from Table</span></span></p>
<p><span style="font-size:12px;"><span style="font-family:'trebuchet ms', helvetica, sans-serif;"> where column1 = 'something'</span></span></p>
<p><span style="font-size:12px;"><span style="font-family:'trebuchet ms', helvetica, sans-serif;"> and ( coalesce(column2,'n') = 'n'</span></span></p>
<p><span style="font-size:12px;"><span style="font-family:'trebuchet ms', helvetica, sans-serif;"> or coalesce(column3,'n') = 'n'</span></span></p>
<p><span style="font-size:12px;"><span style="font-family:'trebuchet ms', helvetica, sans-serif;"> )</span></span></p>
<p> </p>
<p><span style="font-size:12px;"><span style="font-family:'trebuchet ms', helvetica, sans-serif;">Based on the parameters I choose the number of columns to be mentioned inside the braces of the where clause differs. I shall be using if else condition to mention which set of columns to be passed to the query based on the parameter. I want to know if there a possibility that I can substitute the conditions inside braces with a variable and assigning it values in the beforeOpen script like below:</span></span></p>
<p> </p>
<p><span style="font-size:12px;"><span style="font-family:'trebuchet ms', helvetica, sans-serif;">select * from Table</span></span></p>
<p><span style="font-size:12px;"><span style="font-family:'trebuchet ms', helvetica, sans-serif;"> where column1 = 'something'</span></span></p>
<p><span style="font-size:12px;"><span style="font-family:'trebuchet ms', helvetica, sans-serif;"> and ( V )</span></span></p>
<p> </p>
<p><span style="font-size:12px;"><span style="font-family:'trebuchet ms', helvetica, sans-serif;">and in the beforeOpen script as :</span></span></p>
<p> </p>
<p><span style="font-size:12px;"><span style="font-family:'trebuchet ms', helvetica, sans-serif;">this.queryText = this.queryText.replace("V","coalesce(column2,'n') = 'n' or coalesce(column3,'n') = 'n' ");</span></span></p>
<p> </p>
<p> </p>
<p><span style="font-size:12px;"><span style="font-family:'trebuchet ms', helvetica, sans-serif;">I end up getting error while updating this in the Dataset (which is obvious) due to syntax error. Please let me know what would help me achieve this.</span></span></p>
<p> </p>
<p><span style="font-size:12px;"><span style="font-family:'trebuchet ms', helvetica, sans-serif;">Thanks!</span></span></p>
<p><span style="font-size:12px;"><span style="font-family:'trebuchet ms', helvetica, sans-serif;">Neelz</span></span></p>