尝试在 informatica 中运行会话时出现以下错误。
ERROR 10/11/2023 2:56:21 PM node02 READER_1_1_1 RR_4035 SQL Error [
ORA-00932: inconsistent datatypes: expected NUMBER got CLOB
我在源限定符中添加了以下 SQL 查询,以从源中的 CLOB 中提取数据。
select objectid,
db_instance_seq,
REGEXP_SUBSTR(
DATA,
'\|(RES_GetResData_Public_ScreenPrint.*?)\|(.*?)\|(.*?)\|(.*?)\|',
1,
column_value,
NULL,
1
) AS TEXT
from TEST
cross join table(
cast(
multiset(
select level
from dual
where DATA LIKE '%RES_GetResData_Public_ScreenPrint%'
connect by level <= regexp_count(
DATA,
'\|(RES_GetResData_Public_ScreenPrint.*?)\|(.*?)\|(.*?)\|(.*?)\|'
)
)
as sys.odcinumberlist
)
)
您可以使用简单的字符串函数(速度更快)和递归子查询分解子句,而不是使用正则表达式:
WITH rsqfc (objectid, db_instance_seq, data, spos, dpos, epos) AS (
SELECT objectid,
db_instance_seq,
data,
INSTR(data, '|RES_GetResData_Public_ScreenPrint', 1),
INSTR(data, '|', INSTR(data, '|RES_GetResData_Public_ScreenPrint', 1) + 34, 1),
INSTR(data, '|', INSTR(data, '|RES_GetResData_Public_ScreenPrint', 1) + 34, 4)
FROM test
UNION ALL
SELECT objectid,
db_instance_seq,
data,
INSTR(data, '|RES_GetResData_Public_ScreenPrint', epos + 1),
INSTR(data, '|', INSTR(data, '|RES_GetResData_Public_ScreenPrint', epos + 1) + 34, 1),
INSTR(data, '|', INSTR(data, '|RES_GetResData_Public_ScreenPrint', epos + 1) + 34, 4)
FROM rsqfc
WHERE spos > 0
AND epos > 0
)
SEARCH DEPTH FIRST BY objectid, db_instance_seq SET order_id
SELECT objectid,
db_instance_seq,
SUBSTR(data, spos + 1, dpos - spos - 1) AS text
from rsqfc
WHERE spos > 0
AND epos > 0;
对于样本数据:
CREATE TABLE test (objectid, db_instance_seq, data) AS
SELECT 1,
1,
EMPTY_CLOB()
|| '|RES_GetResData_Public_ScreenPrint - AAAAA|BBBB|CCCC|DDDD|' || CHR(10)
|| 'XXXX|RES_GetResData_Public_ScreenPrint - EEEEE|F||H|I|J|K' || CHR(10)
FROM DUAL;
输出:
对象ID | DB_INSTANCE_SEQ | 文字 |
---|---|---|
1 | 1 | RES_GetResData_Public_ScreenPrint - AAAAA |
1 | 1 | RES_GetResData_Public_ScreenPrint - EEEEE |