Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Conditional WHERE clause based on parameter input

John 95126Mar 23 2009 — edited Mar 23 2009
When restricting data based on a parameter I usually use the following:

AND p.start_date = NVL (p_start_date, p.start_date)

so IF the parameter is null THEN I just join on itself, ELSE we filter on parameter.

New requirement involves greater than or equal to, so I tried this:

AND CASE
WHEN (p_start_date = NULL) THEN
p.start_date = p.start_date
ELSE
p.start_date >= p_start_date
END;

but this is, at a minimum, is syntactically wrong.

Any suggestions?

Thanks!
This post has been answered by 12826 on Mar 23 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 20 2009
Added on Mar 23 2009
9 comments
4,058 views