Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Oracle Reports: Setting a Runtime Where Clause in the Report SQL 1

Status
Not open for further replies.

mgmonto

MIS
May 13, 2004
4
US
I have a report that has a start date as an in parameter that can either have a value or be null at runtime. The where clause of my report sql is:
where date_received >= :p_start_date

If I don't put a value in for :p_start_date then no data is returned. How do I set up the where clause of the query so that if :p_start_date is null, then the query should return all records without regarding a start_date? The where clause must also address the potential of :p_start_date having a valid value.

Thanks for your assistance.
 
where date_received >= decode(nvl:)p_start_date, 'X'), 'X', date_received, :p_start_date)
 
The second option is to create write a code in after parameter form and then use it as lexical parameter.

For e.g

After parameter form

if :p_start_date is not null then
lp_date := ' and date_received >= :p_start_date '
end if;

and in the main query add the lexical parameter &lp_date

This approach will be suitable when there are lot of parameters in the report.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top