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!

Checking a parameter with multiple values

863607May 22 2011 — edited May 23 2011
Hello,

I've been searching for answers on this forum but still cannot find an answer to my problem.

Is it possible to do a query like this:

Select table1.column_name
from tb_trn_test table1
IF &&1 IS NULL then table1.column_name in ('Good','Better','Best')
IF &&1 IS NOT NULL then table1.column_name in ('&1')

The &&1 parameter to be passed can be null or can have at least 2 values ('Good','Worst').

I tried to do this but I always get an error when the parameter contains more than 1 value.

Select table1.column_name
from tb_trn_test table1
where
*((((SELECT NVL('&&1',NULL) FROM DUAL) Is Null)*
AND (table1.column_name in ('Good','Better','Best')))
OR
*(((SELECT NVL('&&1',NULL) FROM DUAL) Is Not Null) AND (table1.column_name IN ('&1'))))*

Hope there's someone who could help.

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 20 2011
Added on May 22 2011
7 comments
910 views