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!

Sub Query selection based on parameter value selected

843762Mar 8 2011 — edited Mar 8 2011
I have a parameter, and based on the value selected, I want to run one of two queries. I thought I could do either an IF THEN ELSE, or a CASE, but neither seem to be working.

What I'm trying to do is this:

IF parameter_value = 338 THEN
(RUN THIS SELECT QUERY)
ELSE
(RUN THIS SELECT QUERY)
END IF

or

SELECT CASE WHEN parameter_value = 338 THEN (RUN THIS SELECT QUERY)
ELSE (RUN THIS SELECT QUERY)
END X

I'm getting errors with both. For the CASE statement, it says "too many values". For the IF statement, it just says "invalid SQL statement".

Any suggestions would be appreciated.

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 5 2011
Added on Mar 8 2011
14 comments
4,841 views