0
votes

I'm trying to create a report in BIRT. I've created a stored proc in SQL Server 2008 which works perfectly. However, when I try to run the report in BIRT, it won't run with NULL value.

var DepartmentValue = params["DepartmentValue"].value;
var AccountValue = params["AccountValue"].value;

sqlText = " EXEC SP_Report_ByDept '"+DepartmentValue+"','"+AccountValue+"','"+startdt+"','"+enddt+"' ";

Works perfectly if there is a valid AcccountValue. Any idea how to pass null value for the AccountValue?

Cheers.

1
Bind variables are the solution instead of creating an SQL string manually. That will solve your SQL injection security problem and the null value problem at the same time. - hvb

1 Answers

0
votes

If I understand it correctly you want to pass the string 'null' when the actual parameter is null?

var DepartmentValue = params["DepartmentValue"].value;
var AccountValue = params["AccountValue"].value;

if (AccountValue == null){
    AccountValue = 'null';
}

sqlText = " EXEC SP_Report_ByDept '"+DepartmentValue+"','"+AccountValue+"','"+startdt+"','"+enddt+"' ";