0

Need help in understanding logic. I have 2 tables from different database. There is one field in common but not the data completely.

As an example: table 1 the field data is coming as :test

 table 2 its coming as - select test from tablename

I need to compare and fetch all the data from table 2 where its matching with data in table 1 i.e test .I am trying to use full outer join and then regular match to fetch the records test but its not working. Can someone pls help in understanding the ideal solution for this problem

Sak
  • 61
  • 6
  • Please update your question with enough sample data for the two source tables to illustrate the issue and show the result you are trying to achieve - based on that sample data – NickW Aug 14 '23 at 16:25

1 Answers1

0

You can use a SQL transformation or you can use the method you are using full join and instr().

A. Using SQL transformation -

Use table1 as Source qualifier. Pass the column you want to match (lets assume the col name is match_col).

  1. Use an expressoion to add % to match_col.
  2. Use passive SQL transformation with static SQL. SQL would look like
SELECT t2.col1, t2.col2 FROM table2 t2 WHERE t2.match_col like ?match_col?
  1. capture all columns from table1 and new columns from table2 and pass them to the target. Mapping will be like
SQ --> EXP --> SQL_Transform -> Tgt

B. Using full join and instr() - This is an in-effieicnt method but it will work when the data volume is low.

  1. Use joiner to join table1 and table 2. do a full outer join on dummy columns.
  2. Use an expression transformation. Create a port like this
match_nomatch = iff( instr(upper(table1_match_col), upper(table2_match_col))>0, 'Match','No Match')
  1. Add a filter with condition - match_nomatch ='Match'

Mapping will be like

SQ --> |
SQ_2--> JNR -> EXP--> FIL-->Tgt
Koushik Roy
  • 6,868
  • 2
  • 12
  • 33
  • Hi @Koushik - Thank you for providing the efficient solution...regarding the first solution the issue is both tables are in different database and have different connections.Just wondering how will it work if having different connection string. – Sak Aug 15 '23 at 09:25
  • Hi @Koushik - Thank you for providing the solution...regarding the first solution ,I have added expression as '%'||FIELD_NAME||'%' and in sql I have provided the output field as like .Just wondering if there are 27 rows with field name ,how will informatica perform this action internally...i can undestand for one value it will be like '%value%' but if we have multiple values how will it handle that....Also i have one field where we are aggregating the data i.e clob.Will it be handled ? – Sak Aug 15 '23 at 10:20
  • I think you can point SQ to Database 1 and SQL transform to Database2. – Koushik Roy Aug 15 '23 at 10:21
  • I think its more complex than i thought. Can you pls give some example for better clarity. Also, if you have only 27 rows, i think infa can handle it. – Koushik Roy Aug 15 '23 at 10:23
  • This is my query not workin:select XMLAGG(xmlelement(e,osa.attr_value, ' ').extract('//text()')ORDER BY osa.line_no).getclobval() attr_value,osa.SESSION_ID from test1.SWIDGET_ATTR osa, test1.task ot where ot.TASK_ID = osa.SESSION_ID and ot.TASK_TYPE = 18 and osa.attr_value like ?o_object_name? and ot.VERSION_NUMBER =(select max(VERSION_NUMBER) from test1.opb_task where ot.TASK_ID = TASK_ID and ot.TASK_TYPE = TASK_TYPE) and osa.VERSION_NUMBER = ( select max(VERSION_NUMBER) from test1.OPB_SWIDGET_ATTR where osa.SESSION_ID = SESSION_ID a ) group by osa.SESSION_ID, ot.SUBJECT_ID,ot.TASK_NAME – Sak Aug 15 '23 at 10:35
  • Hi @Koushik-Is there any way to fetch only search value that's not matching with string.Example match_nomatch = iff( instr(upper(table1_match_col), upper(table2_match_col))>0, 'Match','No Match') .In this case I got the matching records with values but I want to only get the search value where its not matched.In this case search value is table2_match_col.How can I find that? – Sak Aug 15 '23 at 17:21
  • you can put a filter after the expression transformation to exclude matching records. Filter condition will be `match_nomatch <>'Match'` – Koushik Roy Aug 16 '23 at 05:25