【问题标题】:adding conditional prompt to Cognos 10 sql based query向基于 Cognos 10 sql 的查询添加条件提示
【发布时间】:2017-01-25 14:09:06
【问题描述】:

Cognos BI 版本:10.2.2 使用 Report Studio
我有一个带有一个提示 p1 的报告,它是一个基于 sql 查询的报告。
提示界面: p1是一个DropdownList(使用值,显示值)
1-全部、2-值2、3-值3、4-值3

我正在尝试为 sql 查询添加基于条件的提示语法..

select col1, col2, col3, col4 from table1
where col4  is not null
case when #Prompt('p1')# = 1 then ' and 1=1'
     when #Prompt('p1')# = 2 then ' and col1 is null and col2 is not null'
     when #Prompt('p1')# = 3 then ' and col1 is not null and col2 is null'
     when #Prompt('p1')# = 4 then ' and col1 is null and col2 is null'
end

我尝试在网上使用大量语法搜索,但找不到与我的场景相关的示例。我需要帮助以实现正确的语句编写方式以满足我的要求。感谢任何帮助..

【问题讨论】:

  • 你的问题是?
  • 对不起。我尝试在网上使用大量语法搜索,但找不到与我相关的示例。我需要帮助以实现正确的语句编写方式以满足我的要求。

标签: sql prompt cognos cognos-10 cognos-bi


【解决方案1】:

通常我建议您发布错误,但这似乎很明显

select col1, col2, col3, col4 from table1
where col4  is not null
and (
(#Prompt('p1','token','0')# = 1) OR
(#Prompt('p1','token','0')# = 2 and col1 is null and col2 is not null) OR
(#Prompt('p1','token','0')# = 3 and col1 is not null and col2 is null) OR
(#Prompt('p1','token','0')# = 4 and col1 is null and col2 is null)
)

【讨论】:

  • 我做了一些在线搜索。遇到以下很有帮助的宏语法。 #prompt('name','datatype','default','pretext','source','posttext')#.我尝试插入我的代码并尝试执行此操作#Prompt('p1','string','1',' and 1=1')# 它给了我 RQP-DEF--177 error sqlprepareoptions status = 9..语法很混乱..
  • 我改变了答案 - 这应该使提示成为可选的。是的,语法非常混乱!
猜你喜欢
  • 1970-01-01
  • 2014-08-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-06-19
  • 1970-01-01
  • 2017-09-29
  • 2018-10-29
相关资源
最近更新 更多