Created
April 30, 2024 15:56
-
-
Save hoogenm/242c8ca57c5e8927a6e640570a06be96 to your computer and use it in GitHub Desktop.
Split/splitting a comma delimited string in Oracle (PL/) SQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select regexp_substr('1,2,3,4','[^,]+', 1, level) | |
from dual | |
connect by regexp_substr('1,2,3,4', '[^,]+', 1, level) is not null; | |
-- Nice, smart, declarative way to split a comma-delimited string in Oracle SQL. | |
-- From: https://forums.oracle.com/ords/apexds/post/the-fastest-way-to-convert-comma-separated-list-into-table-3353 | |
-- This may be slow for a long string, but for parsing a config value this results in concise code and may prevent boilerplate code. | |
-- Replace the 'copied & pasted' string (e.g. '1,2,3,4' in the example above) by one variable/constant in PL/SQL. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment