开发者

iReport - parameterize schema name?

开发者 https://www.devze.com 2023-03-20 15:12 出处:网络
I have the following query : SELECT blah FROM \"PUBLIC\".\"MYACTIVITY\" MYACTIVITY The problem is, the schema name is different for different environments. I tried making \"PUBLIC\" a parameter lik

I have the following query :

SELECT
     blah
FROM
     "PUBLIC"."MYACTIVITY" MYACTIVITY

The problem is, the schema name is different for different environments. I tried making "PUBLIC" a parameter like this:

SELECT
     blah
FROM
     "$P{schemaName}"."MYACTIVITY" MYACTIVITY

while setting schemeName before I compile the report in the params, but no matter what I 开发者_如何学Cdo, or what the default value is set as, I get the following error:

Error:SQL problems:invalid schema name: ? in statement [SELECT blah FROM "?"."MYACTIVITY" MYACTIVITY

How do I properly parameterize the schema name for this report?


Try using $P!{schemaName}. Note the exclamation mark. Use double quotes in the value:

SELECT
     blah
FROM
     $P!{schemaName}."MYACTIVITY" MYACTIVITY

And:

Let schemaName = "PUBLIC" (include the quotes).

The $P{} substitution provides an interpreted value, whereas $P!{} uses the literal value. You can use $P!{} to change the query itself.

0

精彩评论

暂无评论...
验证码 换一张
取 消