2017-01-20 94 views
0

我有三個參數$P{Clss}(從船上選擇類),$P{MinWeight}$P{MaxWeight}。每當我離開$P{Clss}空白它總是顯示任何頁面。Jaspersof iReport - 如何返回所有記錄參數爲空時

我的WHERE子句有什麼問題?我試過這個。

where first.class = $P{Clss} or $P{Clss} is null and displacement between $P{MinWeight} and $P{MaxWeight} 


where $P{Clss} is null or $P{Clss} = first.class and displacement between $P{MinWeight} and $P{MaxWeight} 

我閱讀博客和與此相關的問題,但不知何故,始終不顯示任何頁面或我想我真的這裏只是一個菜鳥。

回答

0

在碧玉報告,需要在不同的方式來處理這種情況如下圖所示,

  • 創建一個名爲ClassParsed(只是命名約定)的新參數。
  • 在參數表達,提供儘可能$P{Clss} != null && !$P{Clss}.isEmpty() ? " first.class = '"+$P{Clss}+"'" : "true"
  • 然後在查詢中有類似下面

where $P!{ClassParsed} and displacement between $P{MinWeight} and $P{MaxWeight}

如果你不給值參數$ P {CLSS}然後參數ClassParsed將成爲如下圖所示,

where true and displacement between $P{MinWeight} and $P{MaxWeight}

如果你給值參數$ P {} CLSS如說Class1,那麼參數ClassParsed將成爲像下面

where first.class = 'Class1' and displacement between $P{MinWeight} and $P{MaxWeight}

希望這會幫助你。

0

兄弟,你必須在定義jasper參數時使用括號,

where first.class = ($P{Clss} or $P{Clss} is null) and displacement between $P{MinWeight} and $P{MaxWeight} 

即時通訊使用這些參數來獲取用戶的位置,

select * from location where 
a.state = $P{state} and 
(a.district = $P{district} or $P{district} is null) 

如有區參數爲null,則還報告獲取生成。 PS:Cheers !!

PS:乾杯!

+0

哎呀我忘記告訴主要的罪魁禍首:D,**看到更新的答案** ..(Y) –

相關問題