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)
How to get sql query?
dzish
Hi,
has BIRT a way to get real sql query which executed? It means without "?" for parameters or without going to database server.
thank you
Find more posts tagged with
Comments
mwilliams
Hi dzish,
You can grab the query in the dataSet script with 'this.queryText'. You can set that to a variable and display it on the report in a dynamic text element to view it.
Hope this helps.
dzish
Hi,
Execuse me for late reply, I expected answer in email.
Thank you Michael but I meant real sql. On tomcat I'm able able to catch the query but in Eclipse I don't know the way how to get.
For example by queryText I have "SELECT id,name FROM family WHERE id=?"
and i would like to get sql query send to sql server like "SELECT id,name FROM family WHERE id=22".
I would like to know if birt have abilities to get the sent sql query.
dzish
I would like to log real sql queries...
Otherwise I will not log the real sql queries ;-)
thank you
mwilliams
dzish,
I think the only queryText you can get still has the ? in them if you use the dataSet parameters. One thing you could do would be to build the "where" statement in your beforeOpen script of your dataSet rather than using dataSet parameters. You'd just use the report parameters like:
this.queryText = this.queryText + " where blah = " + params["paramName"];
Or, you could use the .replace() function and replace the '?'s in your queryText string with the parameter values. The first suggestion is probably the better of the two though.
dzish
thank you Michael,
I will use the first way - doing WHERE part in handler.
I need the real sql because of logging complicated queries and in case of problems I will be able to invoke the query.
mwilliams
dzish,
You're welcome. Let me know if you run into any issues.
dzish
Hi,<br />
<br />
today I had another problem with sql query. Birt dataset query was ok but returned data was bad.<br />
My <a class='bbc_url' href='
http://cz.linkedin.com/pub/david-bene-x161/6/bb2/5b'>collegue</a>
; pointed out on possibility to catch traffic in some proxy server.<br />
<br />
1. download and install Trivial proxy on machine<br />
2. run the proxy and set ports and url of database<br />
3. set logging of traffic to file<br />
4. run the proxy<br />
5. set in datasource new connection to localhost and local port of trivial proxy<br />
6. tested connection must be ok<br />
7. run report<br />
8. look at log of the proxy