简体   繁体   English

检查是否满足条件,然后进行查找

[英]check if condition is met then do a lookup

I'm trying to do a parallel job wherein I check the value of a column where in if it matches a certain condition it returns a certain value and if does not it will check on another condition and if it matches that condition it will do a lookup. 我正在尝试做并行工作,其中我检查一列的值,如果它符合某个条件,它将返回某个值,如果不匹配,它将检查另一个条件,如果与该条件匹配,它将执行一个抬头。 I'm not sure where to put the condition if it will be on the reference link or the output link. 我不确定将条件放在参考链接还是输出链接上。

Here is a pseudocode of some sort to hopefully makes is clearer: 这是希望使它更清晰的某种伪代码:

if (table1.colname = NULL OR table1.colname = '')
  then '999'
else 
  if table1.column = 0
     then do a lookup on table2.colname for '1' return table2.colname2
  else
     do a lookup on table2.colname for '2' return table2.colname2
  if value is not found then '999'

I'm kinda new to datastage, so any comments or idea are greatly appreciated. 我是datastage的新手,因此非常感谢您提出任何意见或想法。 And please do let me know if you need other clarifications. 如果您需要其他说明,请告诉我。 Thank you. 谢谢。

Use Transformer or Filter to split the records into three links based on the condition 使用Transformer或Filter根据条件将记录分为三个链接

First Link : Records containing Null or Empty Second Link : Records containing Value Zero third Link : Otherwise ( Remaining records) 第一个链接:包含空值或空值的记录第二个链接:包含值零的记录第三个链接:否则(其余记录)

Then do the look up on second and third link seperately as per the requirement Then Funnel the output from First link and the outputs from Look up Use transformer to apply the fourth condition for non matching records 然后根据需要分别在第二个和第三个链接上进行查找,然后将第一个链接的输出和“查找”的输出合并到一起使用变压器将第四个条件应用于不匹配的记录

     Or

In transformer create a new field in which write condition like 在变压器中创建一个新字段,其中写入条件如下

If NullToEmpty(table1.column)='' then "DefaultValue"(Make sure that the value u are assigning should not have the matching records in reference table) 如果NullToEmpty(table1.column)=''然后是“ DefaultValue”(确保u所分配的值在参考表中不具有匹配的记录)

Else If table1.column = 0 then "1" Else If table1.column = 1 then "2" Else "Defaultvalue" 否则,如果table1.column = 0,则为“ 1”;否则,如果table1.column = 1,则为“ 2”,否则为“ Defaultvalue”

Then do the lookup on this new field with the table2.colname2 and assign "999" in the transformer for the lookup not found records 然后使用table2.colname2在此新字段上进行查找,并在转换器中为未找到的记录分配“ 999”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM