So I am trying to parse out data from this table that has a single identifier (file_name) and there are different attributes such as first_name, last_name, date_of_birth. The catch here is that the other non-identifier columns (such as first_name, last_name, etc.) have multiple entries delimited by im guessing a chr(10). Some of these fields can also be null (as DOB is shown below) So for example: The original data will have: filename.xml johnjacob schmidtmiller, 1-02-03 i need it to become: filename.xml john schmidt 1-02-03 filename.xml jacob miller null
What i have is as follows:
select file_name
, regexp_substr(first_name, '([^chr(10)]*)(chr(10)|$)', 1, level, null, 1) as first_name
, regexp_substr(last_name, '([^chr(10)]*)(chr(10)|$)', 1, level, null, 1) as last_name
, regexp_substr(dob, '([^chr(10)]*)(chr(10)|$)', 1, level, null, 1) as dob
from TABLE
connect by level <= regexp_count(first_name, chr(10)) + 1
and prior file_name = file_name
and prior sys_guid() is not null
order by file_name
I am currently only returning the first first name / last name / dob etc. for each file name. What am I doing wrong?
Thanks in advance!