拆分源数据以获得特定的数据 oracle
splitting the source data to have the specific data oracle
我有一个来自 oracle db table 数据类型 VARCHAR2(512 CHAR) 的源字段,它是这样的
%custId{str:hGl0EWJsRTwweerRkaaKsdKDsqKm0123}
%prod{str:BalanceAmount}%logistic{str:Logistic}%hiringdate{str:1999-02-28T11:10:11p}%custId{str:FpseikiD0Jt1L0Mskdww8oZBjU4La123}
但是当我考虑我的提取物时,我必须只考虑带有 %cusId 拉取数据的数据,并且只有这个字母数字数据必须被捕获并填充用于提取物,问题是这只是源代码中的一个示例可以是任意数量的组合,但我必须只考虑 %custId 与
%custId{str:hGl0EWJsRTwweerRkaaKsdKDsqKm0123}
我需要使用哪个函数substr,lpad?
使用以下查询后
SELECT
field,
REGEXP_SUBSTR(field, '%custId\{.*?\}') AS custId
FROM yourTable
where col_source='%prod{str:BalanceAmount}%logistic{str:Logistic}%hiringdate{str:1999-02-28T11:10:11p}%custId{str:FpseikiD0Jt1L0Mskdww8oZBjU4La123}'
结果
%custId{str:FpseikiD0Jt1L0Mskdww8oZBjU4La123}
但预期结果
FpseikiD0Jt1L0Mskdww8oZBjU4La123
您可以在此处使用 REGEXP_SUBSTR
:
SELECT
field,
REGEXP_SUBSTR(field, '%custId\{(.*?)\}', 1, 1, NULL, 1) AS custId
FROM yourTable;
我有一个来自 oracle db table 数据类型 VARCHAR2(512 CHAR) 的源字段,它是这样的
%custId{str:hGl0EWJsRTwweerRkaaKsdKDsqKm0123}
%prod{str:BalanceAmount}%logistic{str:Logistic}%hiringdate{str:1999-02-28T11:10:11p}%custId{str:FpseikiD0Jt1L0Mskdww8oZBjU4La123}
但是当我考虑我的提取物时,我必须只考虑带有 %cusId 拉取数据的数据,并且只有这个字母数字数据必须被捕获并填充用于提取物,问题是这只是源代码中的一个示例可以是任意数量的组合,但我必须只考虑 %custId 与 %custId{str:hGl0EWJsRTwweerRkaaKsdKDsqKm0123}
我需要使用哪个函数substr,lpad?
使用以下查询后
SELECT
field,
REGEXP_SUBSTR(field, '%custId\{.*?\}') AS custId
FROM yourTable
where col_source='%prod{str:BalanceAmount}%logistic{str:Logistic}%hiringdate{str:1999-02-28T11:10:11p}%custId{str:FpseikiD0Jt1L0Mskdww8oZBjU4La123}'
结果
%custId{str:FpseikiD0Jt1L0Mskdww8oZBjU4La123}
但预期结果
FpseikiD0Jt1L0Mskdww8oZBjU4La123
您可以在此处使用 REGEXP_SUBSTR
:
SELECT
field,
REGEXP_SUBSTR(field, '%custId\{(.*?)\}', 1, 1, NULL, 1) AS custId
FROM yourTable;