Skip to content

Instantly share code, notes, and snippets.

@PWx21
PWx21 / split_strings.sql
Created June 3, 2014 20:07
Split strings in pl_sql
declare
v_result_count number := 0;
v_ids varchar2(2000) := '1234,0987';
begin
select count(*) into v_result_count from
(select trim(regexp_substr(v_ids, '[^,]+', 1, rownum)) id from dual
connect by level <= length (regexp_replace (v_ids, '[^,]+')) + 1) split
where split.id = 1234;
if v_result_count > 0 then