Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Retrieve SQL statement from IRunAndRenderTask
chris_w
I want to log the SQL statement which is fired by the <em class='bbc'>IRunAndRenderTask</em> after all placeholders have been set.<br />
<br />
Is that possible?
Find more posts tagged with
Comments
johnw
The only way I can think of is to either turn the logging level up on the logger you pass into the task, or you can try interacting with the logger in the onOpen event of the report itself.
cypherdj
it's possible to do it within BIRT using the dataset script. If you select your dataset from the outline and click on the script tab, you can add the following to your beforeOpen method:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
importPackage(Packages.java.io);
logFileName = "c:/tmp/birt.log";
out = new PrintWriter(new FileWriter(logFileName, true));
out.println("this.queryText=<" + this.queryText + ">");
out.close();
</pre>
<br />
I find this quite useful to debug my queries.<br />
<br />
hoping that helps,<br />
cedric
chris_w
<blockquote class='ipsBlockquote' data-author="'cypherdj'" data-cid="82931" data-time="1316272364" data-date="17 September 2011 - 08:12 AM"><p>
it's possible to do it within BIRT using the dataset script. If you select your dataset from the outline and click on the script tab, you can add the following to your beforeOpen method:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
importPackage(Packages.java.io);
logFileName = "c:/tmp/birt.log";
out = new PrintWriter(new FileWriter(logFileName, true));
out.println("this.queryText=<" + this.queryText + ">");
out.close();
</pre>
<br />
I find this quite useful to debug my queries.<br />
<br />
hoping that helps,<br />
cedric<br /></p></blockquote>
<br />
The problem in this case is, that parameters aren't replaced. I need to log queries with replaced parameters.
cypherdj
Hmmm, I seemed to remember the parameters had been replaced at that stage, but maybe it was for a specific data set where we had built the parameter values directly into the script.
I'll look into it when I get home this evening, I'm pretty sure I've done this before, but it's been a while
cypherdj
I've been able to log the parameter value separately from the query, if that's any good to you:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>importPackage(Packages.java.io);
logFileName = "c:/tmp/birt.log";
out = new PrintWriter(new FileWriter(logFileName, true));
out.println("entering DataSet.beforeOpen()");
out.println("queryText=" + this.queryText);
out.println("params[param_1]=" + this.getInputParameterValue("param_1"));
out.close();</pre>
<br />
Hope that helps,<br />
Cedric