首页 > 解决方案 > 在 Informatica 中正确使用 SQL 函数 REGEXP_SUBSTR

问题描述

--特定的 Informatica PowerCenter Qs--

我有这样的传入数据字段,需要从连字符的任一侧提取子字符串并将它们存储在目标表的各个字段中。我从数据库中得到了正确的结果,但在 Informatica 中同样不起作用。在表达式中,我的代码说已成功解析,但没有加载任何内容。

如果有人可以帮助我处理所有 8 条 REGEXP 代码行,那就太好了,因为当我深入字符串时,它似乎有很大不同。


select replace(regexp_substr('ABC-10000-DEF-200-*-*-XYZ-*' ,'[^-]*(-|$)',1,1), '-', '' ) from dual;
select replace(regexp_substr('ABC-10000-DEF-200-*-*-XYZ-*' ,'[^-]*(-|$)',1,2), '-', '' ) from dual;
select replace(regexp_substr('ABC-10000-DEF-200-*-*-XYZ-*' ,'[^-]*(-|$)',1,3), '-', '' ) from dual;

select regexp_substr('ABC-10000-DEF-200-*-*-XYZ-*','[^-]+',1,1) from dual;
select regexp_substr('ABC-10000-DEF-200-*-*-XYZ-*','[^-]+',1,2) from dual;
select regexp_substr('ABC-10000-DEF-200-*-*-XYZ-*','[^-]+',1,3) from dual;

INFA Case 1: When I am using the below, its succeeding for the first occurrence but coming as nulls for the other 7 substring extracts. 

REG_EXTRACT(String_Input,'([^-]*),?([^-]*),?([^-]*).*',1) --> Succeeds
REG_EXTRACT(String_Input,'([^-]*),?([^-]*),?([^-]*).*',2) --> Null
REG_EXTRACT(String_Input,'([^-]*),?([^-]*),?([^-]*).*',3) -- Null and so on till 8. 

Case 2: When I use the below, I get all Nulls. 

REG_EXTRACT('String_Input','[^-]+',1,1) --> Null
REG_EXTRACT('String_Input','[^-]+',1,2) --> Null
REG_EXTRACT('String_Input','[^-]+',1,3) --> Null ```

标签: data-warehouseinformaticainformatica-powercenterregexp-replaceregexp-substr

解决方案


推荐阅读