传递数据是更顺序的方式

to pass data is more sequential way

我有五个输入字段

里面可以有数据也可以没有
第2行和第4行可以有数据
有5条记录 示例:如果数据来自第 2 行和第 4 行,那么我们必须发送第 1 行和第 2 行的行输出

我制作了 5 个带有标志 1 和 0 的可变端口
1 如果有数据
0 如果该行中没有数据

我在一个变量端口中使用的代码 I_ADDR_LINE_1

IIF(
NOT ISNULL(I_ADDR_LINE_1_TX)
AND 
NOT IS_SPACES(I_ADDR_LINE_1_TX)
AND 
LENGTH(LTRIM(RTRIM(I_ADDR_LINE_1_TX)))<>0,1,0
)

现在,如果数据来自第 1、3、5 行,输出数据应该按顺序进行,即第 1、2、3 行

如果我理解正确,I_ADDR_LINE_1、I_ADDR_LINE_2、I_ADDR_LINE_3、I_ADDR_LINE_4、I_ADDR_LINE_5 是您输入的列 file/table。如果您在 inpur 文件中收到 I_ADDR_LINE_1、I_ADDR_LINE_3 和 I_ADDR_LINE_5 的数据,您希望将其加载为 I_ADDR_LINE_1、I_ADDR_LINE_2 和 I_ADDR_LINE_3在输出中。

假设我的理解如上所述是正确的,您定义的变量端口逻辑看起来不错,您应该为 ADDR_LINE 2、3、4 和 5 再创建 4 个变量端口,标志值为 1/0 .最后,您应该尝试确定在输出中按顺序加载它。在输出变量中,您应该尝试根据下面提到的嵌套 if else 语句来识别序列。

OUT_VAR_ADDR_LINE_1 = 

IIF(VAR_I_ADDR_LINE_1=1,I_ADDR_LINE_1,
(IIF(var_I_ADDR_LINE_2=1,I_ADDR_LINE_2,
(IIF(VAR_I_ADDR_LINE_3=1,I_ADDR_LINE_3,
(IIF(VAR_I_ADDR_LINE_4=1,I_ADDR_LINE_4,
IIF(VAR_I_ADDR_LINE_5=1,I_ADDR_LINE_5,
NULL)))))))) 

OUT_VAR_ADDR_LINE_2

IIF(VAR_I_ADDR_LINE_2=1,(IIF(OUT_VAR_ADDR_LINE_1 <> I_ADDR_LINE_2),I_ADDR_LINE_2,
(IIF(var_I_ADDR_LINE_3=1,(IIF(OUT_VAR_ADDR_LINE_1 <> I_ADDR_LINE_3),I_ADDR_LINE_3,
(IIF(VAR_I_ADDR_LINE_4=1,(IIF(OUT_VAR_ADDR_LINE_1 <> I_ADDR_LINE_4),I_ADDR_LINE_4,
(IIF(VAR_I_ADDR_LINE_5=1,(IIF(OUT_VAR_ADDR_LINE_1 <> I_ADDR_LINE_5),I_ADDR_LINE_5,
NULL))))))))))) -- 4


OUT_VAR_ADDR_LINE_3

IIF(VAR_I_ADDR_LINE_3=1,(IIF(OUT_VAR_ADDR_LINE_2 <> I_ADDR_LINE_3),I_ADDR_LINE_3,
(IIF(var_I_ADDR_LINE_4=1,(IIF(OUT_VAR_ADDR_LINE_2 <> I_ADDR_LINE_4),I_ADDR_LINE_4,
(IIF(VAR_I_ADDR_LINE_5=1,(IIF(OUT_VAR_ADDR_LINE_2 <> I_ADDR_LINE_4),I_ADDR_LINE_5,
NULL))))))))



OUT_VAR_ADDR_LINE_4

IIF(VAR_I_ADDR_LINE_4=1,(IIF(OUT_VAR_ADDR_LINE_3 <> I_ADDR_LINE_4),I_ADDR_LINE_4,
(IIF(var_I_ADDR_LINE_5=1,(IIF(OUT_VAR_ADDR_LINE_3 <> I_ADDR_LINE_5),I_ADDR_LINE_5,
NULL)))))

OUT_VAR_ADDR_LINE_5

IIF(VAR_I_ADDR_LINE_5=1,(IIF(OUT_VAR_ADDR_LINE_4 <> I_ADDR_LINE_5),I_ADDR_LINE_5,
NULL))

抱歉,它没有用。我不再在 Informatica 工作了。所以我还没有尝试过该代码。它只是给你一个想法的原型。除了实施 this is a informatica,您还有其他方法。只需使用 informatica 执行从源到目标的一对一加载,然后在您的数据库上编写查询。同样,我不确定您是否在项目中使用数据库。我在 Netezza 中编写了以下具有四个级别的子查询的查询。在每个子查询层,我们尝试按顺序加载值。请在示例数据上找到以下查询和测试结果。

--- 源中的数据

select * from test1234;

ID1 | ID2 | ID3 | ID4 | ID5 -----+-----+-----+-----+----- | | 3 | 4 | 5


以下查询的输出。 SRC_* 属性代表源数据,TGT_* 属性代表目标数据。希望对你有帮助

SRC_ID1 | SRC_ID2 | SRC_ID3 | SRC_ID4 | SRC_ID5 | VAR_ID1 | VAR_ID2 | VAR_ID3 | VAR_ID4 | VAR_ID5 | TGT_ID1 | IGT_ID2 | TGT_ID3 | TGT_ID4 | TGT_ID5 ----------+--------+--------+--------+--------+ ----------+--------+--------+--------+--------+ ----------+--------+--------+--------+-------- | | 3 | 4 | 5 | 0 | 0 | 1 | 1 | 1 | 3 | 4 | 5 | | (1 行)

select 
e.ID1 AS SRC_ID1,
e.ID2 AS SRC_ID2,
e.ID3 AS SRC_ID3,
e.ID4 AS SRC_ID4,
e.ID5 AS SRC_ID5,
e.col1 AS VAR_ID1,
e.col2 AS VAR_ID2,
e.col3 AS VAR_ID3,
e.col4 AS VAR_ID4,
e.col5 AS VAR_ID5,
e.abc as TGT_ID1,
e.def AS IGT_ID2,
e.ghi AS TGT_ID3,
e.jkl AS TGT_ID4,      
(case when e.col5=1 and e.abc <> e.id5 and e.def <> e.id5 and e.ghi <> e.id5 and e.id5 <> e.jkl then e.id5 
else null end)as TGT_ID5
from (     
select d.abc,
       d.def,
       d.ghi,              
(case when d.col4=1 and d.abc <> d.id4 and d.def <> d.id4 and d.ghi <> d.id4 then d.id4  
when d.col5=1 and d.abc <> d.id5 and d.def <> d.id5 and d.ghi <> d.id5 then d.id5 
else null 
end)  as jkl,
d.col1,
d.col2,
d.col3,
d.col4,
d.col5,
d.ID1,
d.ID2,
d.ID3,
d.ID4,
d.ID5       
from
(select c.abc,
       c.def,  
(case when c.col3=1 and c.abc <> c.id3 and c.def <> c.id3  then c.id3  
when c.col4=1 and c.abc <> c.id4 and c.def <> c.id4 then c.id4  
when c.col5=1 and c.abc <> c.id5 and c.def <> c.id5 then c.id5 
else null 
end)  as ghi,
c.col1,
c.col2,
c.col3,
c.col4,
c.col5,
c.ID1,
c.ID2,
c.ID3,
c.ID4,
c.ID5       
from (
select b.abc,
(case when b.col2=1 and b.abc <> b.id2 then b.id2  
when b.col3=1 and b.abc <> b.id3 then b.id3  
when b.col4=1 and b.abc <> b.id4 then b.id4  
when b.col5=1 and b.abc <> b.id5 then b.id5 
else null 
end)  as def,
b.col1,
b.col2,
b.col3,
b.col4,
b.col5,
b.ID1,
b.ID2,
b.ID3,
b.ID4,
b.ID5         
from (
select 
(case when a.col1=1 then a.id1  
when a.col2=1 then a.id2  
when a.col3=1 then a.id3  
when a.col4=1 then a.id4  
when a.col5=1 then a.id5 else null 
end)  as abc,
a.*
 from 
(select (case when ID1 is null then 0 else 1 end) as col1,
       (case when ID2 is null then 0 else 1 end) as col2,
       (case when ID3 is null then 0 else 1 end) as col3,
       (case when ID4 is null then 0 else 1 end) as col4,
       (case when ID5 is null then 0 else 1 end) as col5,
       ID1,
       ID2,
       ID3,
       ID4,
       ID5 from test1234 ) a ) b ) c ) d ) e

问候 沙拉斯