Here is the varchar 50% REC.PES/50% PTT that I have in the RFDGENERIC
table.
The task is split by /
.
Here is the query
select
regexp_substr(DESCR, '[^/]+', 1, level) value
from
RFDGENERIC
where
id = 14966150
connect by level <= length(DESCR) - length(replace(DESCR, '/')) + 1
and prior DESCR = DESCR
and prior sys_guid() is not null;
But the result is.
50% REC.PES
50% PTT
50% PTT
If I will create the table and insert into it the same value from RFDGENERIC
the result will be correct.
CREATE TABLE TEST_SPLIT
(
ID NUMBER(20),
DESCR VARCHAR2(128 char)
);
INSERT INTO TEST_SPLIT (id, DESCR)
SELECT id, DESCR
FROM RFDGENERIC
WHERE DESCR = '50% REC.PES/50% PTT'
AND id = 14966150;
SELECT
regexp_substr(DESCR, '[^/]+', 1, level) value
FROM
TEST_SPLIT
WHERE
id = 14966150
connect by level <= length(DESCR) - length(replace(DESCR, '/')) + 1
and prior DESCR = DESCR
and prior sys_guid() is not null;
In this case the result is correct:
50% REC.PES
50% PTT
Notes:
All data types are the same.
I have used other methods as described here. Same result.
DBMS:
Oracle (ver. Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.15.0.0.0) Case sensitivity: plain=upper, delimited=exact Driver: Oracle JDBC driver (ver. 21.5.0.0.0, JDBC4.3)
Here is the question what is the difference?
Why in the first case I am getting the wrong result?