Jump to content

iReport Parameter Help!


hussainian

Recommended Posts

Hi!

I need some help regarding report parameters. I'm filling my report with the record from a table which has, say 10 rows. Each row has a unique id. I've added a parameter which takes this ID at run time and displays corresponding record from table. Now this is it. Using this approach, I can't see the all records of the table in this report. The thing I want is that when the prompt appears, it should have the option whether to display one record for which the parameter value has been entered OR to display all the records of the table without entring the parameter value. If I close the parameter dialog box without entering any value, the generated report is blank, which is logically correct. What am I suppoesd to do to change this behaviour. Or is there any way that I may set such default expression that pressing the Default button show me the full records.

Thanks & Best Regards.

AsadULLAH.

 

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

  • 2 weeks later...

I just restarted work on this problem. Ok let me tell yoy my problem.

I've a table FUND and i want to get its FUND_CODE column. To get all fund_code, I'll write

 

Select FUND_CODE from FUND

 

and to get some specific fund_code through parameter, I'll write

 

Select FUND_CODE from FUND where FUND_CODE=$P{PARAM_FUND_CODE}

 

Now the I'll enter fund code in the parameter prompt. But if I'll want to display all the fund_code, the WHERE clause is extra. My question is how to handle this situation. How adding another Parameter will solve this issue?

 

Thanks.

 

AsadULLAH.

Link to comment
Share on other sites

Hi.

Try out the following ( I Dont know if this works)

Create a parameter and call it for Example WhereClause from type String.

Write in your query:

Select FUND_CODE from FUND $P{WhereClause} $P{PARAM_FUND_CODE}

leave both Parameters empty for a selection of all rows.

If you want to add the where Clause, give $P{WhereClause} the value " where FUND_CODE="

and $P{PARAM_FUND_CODE} the ID.

Greets GevatterTod

 

 

*this is a signature*

 



Post Edited by gevattertod at 10/21/2009 11:41
Link to comment
Share on other sites

Hi,

I did the following to reach it. Perhaps it works for you:

Select FUND_CODE from FUND where (FUND_CODE=$P{PARAM_FUND_CODE}  and $P{PARAM_FUND_CODE} IS NOT null OR $P{PARAM_FUND_CODE} IS null)

this works for an oracle db if you left the Parameter empty to show all entries of the table.

HTH

Christina

Link to comment
Share on other sites

  • 5 years later...

I solve my problem by using the below condition in where clause.

(TableName.ColumnName = NVL($P{Param},TableName.ColumnName or $P{Param} IS NULL)

The above query includes even null values.

If you don't want to include null values, you can just use the NVL function as shown below

TableName.ColumnName = NVL($P{Param},TableName.ColumnName)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...