-2

I have a field in my Oracle table "Table1" with Column "texta" which has all my codes written. I would like to extract all the occurrences which matches the patter "record." or "Record." and list the result. For example:-

Content of texta

CreateRecord = CreateRecord(Record.PS_JOB)
CreateRecord = CreateRecord(Record.PS_NATIONAL_ID)

The expected result is

PS_JOB
PS_NATIONAL_ID
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
Rohit Prasad
  • 135
  • 2
  • 12

1 Answers1

2

See if this helps.

SQL> desc test
 Name                                                  Null?    Type
 ----------------------------------------------------- -------- -------------------
 ID                                                             NUMBER
 TEXTA                                                          CLOB

SQL> select * From test;

        ID TEXTA
---------- ------------------------------------------------------------------------
         1 CreateRecord = CreateRecord(Record.PS_JOB)
           CreateRecord = CreateRecord(Record.PS

         2 CreateRecord = CreateRecord(Record.ABC_DEF)
         3 CreateRecord = CreateRecord(Record.LITTLE_FOOT)

SQL> select id,
  2    regexp_substr(texta, 'Record\.\w+', 1, column_value) result
  3  from test cross join
  4       table(cast(multiset(select level from dual
  5                           connect by level <= regexp_count(texta, 'Record\.')
  6                          ) as sys.odcinumberlist));

        ID RESULT
---------- ------------------------------------------------------------------------
         1 Record.PS_JOB
         1 Record.PS_NATIONAL_ID
         2 Record.ABC_DEF
         3 Record.LITTLE_FOOT

SQL>
Littlefoot
  • 131,892
  • 15
  • 35
  • 57
  • You're welcome. As of downvoting: I wouldn't know who did it, but yes - it would help if downvotes required explanation (or if that person posted a(n anonymous) comment). – Littlefoot Mar 26 '20 at 13:53