2017-01-20 5 views
0

$P{Clss}(船からのクラスを選択)、$P{MinWeight}および$P{MaxWeight}の3つのパラメータがあります。 $P{Clss}をブランクのままにすると、常にページが表示されません。Jaspersof iReport - パラメータがnullの場合、すべてのレコードを返すことができます

私の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} 

私は、これに関連するブログや質問を読んで何とかそれは常に何のページを表示しませんか私は、私がここに本当にただのnoobだと思います。以下のようなジャスパーレポートで

答えて

0

、あなたは別の方法でこのケースを処理する必要があり、

  • ClassParsed(ちょうど命名規則)という名前の新しいパラメータを作成します。パラメータ表現で
  • 、クエリで次に$P{Clss} != null && !$P{Clss}.isEmpty() ? " first.class = '"+$P{Clss}+"'" : "true"
  • あなたはパラメータ$ P {CLSS}に値を与えていない場合は、パラメータClassParsedになるだろう

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

以下のようなものを持っているとして提供

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

場合は、以下のようなClass1が言うように、あなたは、パラメータClassParsedが、これはあなたを助けるでしょう

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

以下のような希望となり、パラメータ$ P {} CLSSに値を与えます。

0

兄弟の場合、ジャスパーパラメータを定義するときに角括弧を使用する必要があります。地区のパラメータのいずれかがnullの場合

ユーザーの場所を取得するために、これらのパラメータを使用して
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) 

はその後も生成されますを報告します。

PS:乾杯!

+0

私は主人に忘れてしまった:D、**更新された回答を参照** ..(Y) –

関連する問題