2017-01-24 47 views
0

Cognos BI版本:10.2.2使用報告工作室
我有一個提示p1及其基於sql查詢的報告。
提示UI: P1是DROPDOWNLIST(使用價值,顯示值)
1-ALL,2-值2,3-值3,-4-值3向Cognos 10基於sql的查詢添加條件提示

我試圖添加條件基於提示語法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 

我試圖在網上使用很多語法搜索,但找不到與我的方案相關的示例。我需要在實現書寫,以滿足我的requirement.any幫助表示讚賞的語句的正確方法幫助..

+0

而你的問題是什麼? – GurV

+0

對不起。我試圖在網上使用大量的語法搜索,但無法找到有關我的例子。我需要幫助實現寫出這些陳述的正確方式來滿足我的要求。 – fidel

回答

0

通常情況下,我建議你張貼的錯誤,但是這一次似乎是顯而易見的

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) 
) 
+0

我做了一些在線搜索。遇到下面的宏語法是有幫助的。 #prompt(「姓名」,」數據類型」,」缺省」,」藉口」,」源」,」 posttext」)#。我嘗試插入我的代碼,並試圖執行此操作#Prompt('p1','string','1','and 1 = 1')#並且它給了我RQP-DEF - 177錯誤sqlprepareoptions狀態= 9 ..這很令人困惑的語法.. – fidel

+0

我改變了答案 - 這應該使提示可選。是的,語法非常混亂! –