Home
Analytics
How to escape single quotes in the input parameters ?
new4BIRT
Hello forum,
I am designing a BIRT report that is using dynamic binding.
I have a string input parameter that might contain values like: "Test's Area", "Developer's Area". In short, the parameter value might contain single quotes in it.
In the property binding section of the dataset, I need to make sure that the paramater value is passed with escaping quotes, before I create a SQL query using it.
Any suggestion on how to do it? I tried doing it using foillowing script but looks like I am doing something wrong. I read on some website that we need to add one more single quote to the existing value (i.e. "Test's Area" will become "Test' 's area") so that the database query will run successfully
var buName = params["Area"].value;
if(buName.indexOf("'")>=0)
{
buName.replace("'", "''");
}
var newBUName = buName;
Any help will be greatly appreciated.
Thanks,
Find more posts tagged with
Comments
bhanley
I am not sure around the specifics of your example, but I do not believe you need to do any additional work. The query parser handles all that for you. Are you seeing a specific error that I can try and replicate?
I have attached a working sample that takes a customer name with a single quote in it as a parameter value and uses that parameter in the query.
Sample is on BIRT 2.3.2 using Classic Models data.
Let me know if this get things working or we need to dig a little deeper.