SQL Developer (MOSC)

MOSC Banner

convert string to list to use IN function

in SQL Developer (MOSC) 4 commentsAnswered ✓

Hi all,

I have a parameter that users can insert comma delimited text. For example p_num = (1,2,4,5)

in a query for the where clause I would like to filter it by p_num, However p_num is optional it maybe null, How do I get all rows to show if p_num is null?

I have this but only shows rows when I have a value in p_num

where

p_num_value in (SELECT
regexp_substr(:p_num, '[^,]+', 1, level)
FROM
dual
CONNECT BY
regexp_substr(:p_num, '[^,]+', 1, level) IS not NULL

)

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center