0

I have a table(target) which has 5 rows, one of the columns name:slno have values (12,13,14,34,56), I need to load data from my source table to target based on the max value of target.

Example :

If in the source table for slno column values are (12,13,14,34,56,88,89,90,99) then only (88,89,90,99) values should go to target (along with all row values), basically I need to find max from target and based on that I need to load rows after that value.

I tried using tJavaRow, tSetGlobalVar, tAggregateRow, but not able to figure out how to map.

syncdm2012
  • 445
  • 2
  • 10
  • 22

1 Answers1

0

There are many ways you can do this.

If your source and target tables are on the same database, you can filter your source query like this:

select *
from source
where slno > (select max(slno) from target)

And then load the rows in your target table.

But if they are not, you can do it in Talend :

enter image description here

The lookup on target gets the max value of slno :

SELECT max(slno)
FROM target

Its schema contains only one column (max_slno):

enter image description here

And inside the tMap, only send the rows where the source's slno is greater than the maximum value of target's slno :

enter image description here

Ibrahim Mezouar
  • 3,981
  • 1
  • 18
  • 22
  • Thanks a ton @iMezouar, can you please share the "component" for jdbcinput_2_target which is used for SELECT max(slno) FROM target.. – syncdm2012 Jan 12 '18 at 12:15
  • It's pretty simple: https://i.imgur.com/zAlUL0W.png There's only one column. Also, notice how inside the tMap there is no join between the inputs, as the lookup only returns one value. If this answers your question, consider accepting my answer. – Ibrahim Mezouar Jan 12 '18 at 12:47
  • Sorry to say, not able to open the png. I used a tmysqlrow(in my case) for lookup component like u did " jdbcinput_2_target"and supplied SELECT max(slno) MAXID FROM target in the query tab( Only one column).but thats not appearing on the row2 tmap( like u have max_slno above) – syncdm2012 Jan 12 '18 at 12:59
  • I've updated my answer with the screenshot. My guess is you didn't set the schema for your component ? Please see my updated answer. You need to set a single column for your lookup component. – Ibrahim Mezouar Jan 12 '18 at 13:04
  • Yes. correct only but still getting Exception in component tMap_1 (actor) java.lang.NullPointerException. – syncdm2012 Jan 12 '18 at 13:47
  • I have exactly same structure but somewhere getting wrong. – syncdm2012 Jan 12 '18 at 13:55
  • I have added the image above – syncdm2012 Jan 12 '18 at 14:04