This can be quite misleading. It occurred when a delimited list was split into its element as a table. Actually, it was a bad handling of code. There were several instances in PL/SQL to split a list. One of them only was to get a count. Actually, two bad handlings. The first one, the splitting was repeated and not done once putting the result in a table type variable to retrieve the count from there. The other one was, a fix having gone wrong a bit. To improve/facilitate test, there was put an order clause to stabilise the order of the result.
WITH CONSTS AS
(SELECT ';0509;0543;509;543;545;' AS ZL_LISTE
,';2;2;2;2;4;' AS HZL_LISTE
,';' AS v_delim
FROM dual
)
,BASE AS
(SELECT RTRIM (LTRIM (ZL_LISTE,v_delim),v_delim) AS v_przl_codes
,RTRIM (LTRIM (HZL_LISTE,v_delim),v_delim) AS
v_przl_origins
,'[^' || v_delim || ']+' AS v_regexp_delim
,v_delim
FROM CONSTS
)
SELECT COUNT (*)
FROM (SELECT TRIM (REGEXP_SUBSTR (v_przl_codes,v_regexp_delim,1,LEVEL))
str
FROM BASE
CONNECT BY LEVEL <= REGEXP_COUNT (v_przl_codes,v_delim) +
1)
code_tab
WHERE
str IN (203
,208
,372)
OR str BETWEEN 2051 AND 2099
ORDER BY level ASC -- this order causes ORA-01788