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)
Dynamic Table Name In Data Set
MarkW
How can I change the table name in an SQL query using a passed in parameter? I tried using the Dataset Property
Binding section, but I keep getting an error:
Cannot get the result set metadata. SQL statement does not return a ResultSet object.
You have an error in your SQL syntax;.....
Below is an example of what I used in the Property Binding without passing in a parameter.
When I use the same query in the Dataset Query section, it works. But for some reason, I can't get this simple query to work in the Property Binding.
I was able to in previous versions of BIRT (version2.5.2). Currently using BIRT 3.7.1
var sql='select * from test';
sql;
Find more posts tagged with
Comments
mwilliams
There's definitely a bug with this. When I do something similar in a report, the property binding takes effect, but it doesn't show in the dataSet in the data explorer. However, if I drop in a table, bind it to my dataSet and create a binding that SHOULD be in the table according to the new query in my property binding, it shows up correctly. Please log a bug for this at
http://www.birt-exchange.org/org/resources/bug-reporting/
. Thanks!
Tubal
I've been able to do this using the BeforeOpen event of the dataset. It's in the 'Advanced' section of the property editor.
You can name your table something unique, and then just replace that text with the table name your parameter holds.
This is what I have in there:
this.queryText = this.queryText.replace("stockxxx", "stock" + params["branch"].value);
it replaces any instance of "stockxxx" with whatever "branch" the user passes. "stockslc" for example.
Or if you're set on doing it in the property binding, it's like this:
"select * from test "
it's just the same thing you'd put in the query window, converted to js (note you don't need the ; at the end of the query). You don't need to set it as a variable. If you had a more complex query with multiple lines, you would do it like so:
"select * from test " +
"where test.test = 'abc' " +
"and test.test2 = ' + params["abc2"] + "' "