zundarz
zundarz

Reputation: 1594

How to extract matched line of a multiline record in Oracle?

I have a multi-line field in this Fiddle of Oracle 11g table. Using SQL, how can I extract the last line that matches 'Export'. This question helps with the regex for the last occurrence but I'm still not getting my desired results.

Desired Results

1,[27-SEP-12] NOT for export

2,[27-SEP-12] OK for export

Upvotes: 0

Views: 1870

Answers (1)

Egor Skriptunoff
Egor Skriptunoff

Reputation: 23757

select 
  customer_id,
  regexp_substr(exp_comment,'.*'||chr(10)||'(.*Export)', 1, 1, 'n', 1) as export
from export_comments 

fiddle

Upvotes: 2

Related Questions