|
Re: Displaying Query Text in BIRT Report [message #719029 is a reply to message #719010] |
Thu, 25 August 2011 20:39 |
|
Take a look at the attached example. One expression shows how to get
the query definition and the other shows a script in the afterOpen to
get the executed query.
Jason
On 8/25/2011 3:14 PM, mwagley wrote:
> Please bear with me, as I am a newbie :)
>
> Is there an easy way of displaying the Query Text along side the results
> in a BIRT report?
> For example, I have a Dataset called "A1". For example, I am using the
> following SQL Query to create the data set:
>
> "select trunc(sydate) from dual"
>
> In the final report, I want to see something like this in a GRID:
>
> Query Text select trunc(sysdate) from dual
> Result
> 08/25/2011
>
> If anyone can help me with this, I'd really appreciate it!
|
|
|
|
|
|
|
Re: Displaying Query Text in BIRT Report [message #1625926 is a reply to message #1625308] |
Fri, 20 February 2015 18:28 |
|
I made a change to the query in the above example to add " and quantityordered > ?", set the value to 25 in the parameters section of the data set editor, and finally, changed the script in the afterOpen to this:
importPackage(Packages.java.lang);
var qry = this.queryText;
var temp = qry.replace("?","--");
temp = temp.split("--");
var newqry = "";
for(i=0; i<temp.length; i++){
newqry = newqry + temp[i] + this.getInputParameters().values().toArray()[i];
}
reportContext.setGlobalVariable("myquery", newqry);
It worked for me in this simple case. For whatever reason, split wouldn't work for "?", so I had to replace it with "--" beforehand. That's why that is in there.
Michael
Developer Evangelist, Silanis
[Updated on: Fri, 20 February 2015 18:30] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.02113 seconds