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!

Is it possible to use a case statement when joining different tables based on input parameters?

1048939Oct 19 2013 — edited Oct 26 2013

Hi,

I have a scenario where my stored procedure takes 5 parameters and the users can pass NULL or some value to these parameters and based on the parameters, I need to pull data from various tables.

Is it possible to use a case statement in the join, similar the one in the below example. I'm getting error when I use the below type of statement.

select a.*

from a

case

when parameter1=1 then

inner join a on a.id = b.id

when parameter1=2 then

inner join a on a.id = c.id

end;

Please let me know, if this type of statement works, and if it works will it create any performance issues?. If the above doesn't work, could you please give me some alternate solutions?

Thanks.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 23 2013
Added on Oct 19 2013
8 comments
6,261 views