Oracle SQL 列出 Clob/Blob 字段中出现的所有字符串
Oracle SQL to list all occurrences of string in Clob/Blob Field
我的 Oracle table "Table1" 中有一个包含列 "texta" 的字段,其中包含我编写的所有代码。
我想提取所有与模式 "record." 或 "Record." 匹配的事件并列出结果。例如:-
texta 的内容
CreateRecord = CreateRecord(Record.PS_JOB)
CreateRecord = CreateRecord(Record.PS_NATIONAL_ID)
预期结果是
PS_JOB
PS_NATIONAL_ID
看看这是否有帮助。
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>
我的 Oracle table "Table1" 中有一个包含列 "texta" 的字段,其中包含我编写的所有代码。 我想提取所有与模式 "record." 或 "Record." 匹配的事件并列出结果。例如:-
texta 的内容
CreateRecord = CreateRecord(Record.PS_JOB)
CreateRecord = CreateRecord(Record.PS_NATIONAL_ID)
预期结果是
PS_JOB
PS_NATIONAL_ID
看看这是否有帮助。
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>