¿如何在 BIRT 的引号查询中加载参数?

¿How to load a parameter in a query in quotes in BIRT?

我有一个用引号括起来的查询:

DECLARE @PivotQuery AS NVARCHAR(MAX),
        @PivotColumns AS NVARCHAR(MAX),
        @PivotNull AS NVARCHAR(MAX)
SELECT @PivotColumns= ISNULL(@PivotColumns + ',','') + QUOTENAME(DepId)
FROM (SELECT DISTINCT sp.DepId FROM SKDEP sp) AS Stock
SELECT @PivotNull 
    = ISNULL(@PivotNull + ',','')
    + 'ISNULL(' + QUOTENAME(DepId) + ', 0) AS '
    + QUOTENAME(DepId)
FROM (SELECT DISTINCT sp.DepId FROM SKDEP sp) AS Stock
SET @PivotQuery =
N'SELECT P.P, P.D, '+@PivotNull+'
FROM
        (
            select 
                s.prdid as P,
                p.prddsc as D,
                case when mstes=''S'' then sum(-MstCntDisp) else sum(MstCntDisp) end as Stock,
                s.DepId
                from SKMOV S
                join PRODUC P on s.PrdId=p.PrdId
                where s.mstsal>0 AND s.MstTpo=''S'' and s.PrdId=**''*TF033''**
                group by s.prdid, p.PrdDsc, s.MstES, s.depid
        ) AS t
PIVOT(sum(Stock)
FOR DEPID IN (' + @PivotColumns + ')) AS P'
EXEC sp_executesql @PivotQuery

在 where 子句中我需要用问号指定我的参数,所以:

and s.PrdId=?

但是我不知道在用引号括起查询时如何指定参数,因为它不接受它。

最后我这样解决了我的问题:

在where子句中,我传递了一个字符串的值,

where s.mstsal>0 AND s.MstTpo=''S'' and s.PrdId=''PRODUCT_ID''

打开报告后(在选项卡 Script/beforeOpen 中),我用参数替换字符串值。

this.queryText=this.queryText.replace("PRODUCT_ID",params["ID"].value);

并且有效!