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!

Extracting a specific value from parameter list

syed haiderJan 4 2023

I have a parameter "Category_ID". I'm passing values (1, 914, 1715, 212).
a) In my case statement, I want to show 4 when 1, 914, and 1715 values are passed.
How can I achieve the above in Oracle SQL query?
select case when :category_id in (1, 914, 1715) then 4 else 0 end test_category
from dual
The above will only let me pass a single value in :category_id parameter.
b) I also wanted to know that if I'm passing multiple values, is there a way for me to extract a single value? For example, I'm passing (1, 914, 1715, 212) in the category_id parameter, how can I extract only number 1 from this parameter?

Comments
Post Details
Added on Jan 4 2023
2 comments
870 views