#1 2007-12-06 13:34:08

tle
Member
Registered: 2007-03-19
Posts: 67

Read previous row

Tags: [database, date, java, sort]

Hi,

Which component can I use to compare the previous row and the current row.
I try to explain my problem. I have many same rows with a different date, and I want to take only the most recent one.  I will sort (in descend order) to have the most recent row at the first position. My Application is in JAVA. I have to load the Data from AS400 to Postgresql.
I have already use tDBInput and tPostgresqlOutput, it’s OK , but I don’t know how to filter thi first row with the most recent Date.

Thanks in advance for your Help.

tle

Offline

#2 2007-12-07 04:20:28

shong
Talend team
Registered: 2007-08-29
Posts: 10297
Website

Re: Read previous row

Hi

Use the tSortRow component to sort the date.
tDBInput-->tSortRow--->tPostgresqlOoutput

Best regards

        shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#3 2007-12-07 08:14:07

tle
Member
Registered: 2007-03-19
Posts: 67

Re: Read previous row

Hi Shong,

Thanks four your answer, I think that I will use tSortRow, but how can I compare the previous row to the current row, with which component ? Because I would like to get the most recent row .

tle

Offline

#4 2007-12-07 09:28:38

shong
Talend team
Registered: 2007-08-29
Posts: 10297
Website

Re: Read previous row

Hi

If you just want to get the most recent row, Can't tSortRow component fit your need? I don't know why you will read the previous row and compare the previous to the current row.
I create a simple job to show how to read the previous row and compare it to the current row. Please see the screenshots
tFileInputCSV:
25
12
36
245
24
85
100

Best regards

        shong


Uploaded Images


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#5 2007-12-07 09:40:49

tle
Member
Registered: 2007-03-19
Posts: 67

Re: Read previous row

How can you get the previous row, can you show your tMap, I don't know the syntax to get the previous  . I want to read the previous row because I have to ignore them and get only the most recent one (filter on the date)

tle

Offline

#6 2007-12-07 09:50:31

shong
Talend team
Registered: 2007-08-29
Posts: 10297
Website

Re: Read previous row

Hi

I have compressed the screenshot of tMap as it is too big. Can you see it clearly?

Best regards

         shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#7 2007-12-07 10:00:50

tle
Member
Registered: 2007-03-19
Posts: 67

Re: Read previous row

Oh, Sorry I didn't see your tMap ,  I have seen only your Job. But it's OK for the syntax to get previous. It's special, globalMap and PREVIOUS_ID , is it the Talend's reserved Word ?

Thanks for all your help.

tle

Offline

#8 2007-12-10 06:22:10

shong
Talend team
Registered: 2007-08-29
Posts: 10297
Website

Re: Read previous row

Hi

The globalMap.put("variableName",value) defined a global variable and globalMap.get("variableName") get the value of the variable.

Best regards

         shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#9 2007-12-10 10:28:22

tle
Member
Registered: 2007-03-19
Posts: 67

Re: Read previous row

Hi,

I have to work with a counter in my job begenning with a value of 100'000 . I have create a tJavaflex with a start code like this "globalMap.put("ID_PERSONNE_D",100000L);".
But in my tRunjob I can't retrieve my counter's value.
I have logged the tJavaflex, and it's ok, I have my  counter's value , but I can't use it with a tRunJob. It's my screenshots below. Perhaps there is another solution to initialize a counter at the beginning of a Job, but tJavaflex and tRunjob, it's not OK. Or I have make mistake somewhere ?

Thanks for your help.

tle


Uploaded Images

Offline

#10 2007-12-10 16:53:30

tle
Member
Registered: 2007-03-19
Posts: 67

Re: Read previous row

Hi,

Please, somebody can help me for my problem of using globalMap and tJavaFlex ? I only want to increment a counter beginning at 100000 (the increment is necessary if records change, because I have many same records)
I have search a lot, but I don't find documentation for tJavaFlex, globalMap......

Thanks a lot if someone can help me

tle

Offline

#11 2007-12-11 08:19:20

shong
Talend team
Registered: 2007-08-29
Posts: 10297
Website

Re: Read previous row

Hi

If you want to pass a parameter from father job to child job, you should define a context in child job, then use tRunJob component to run the child job and pass the parameter.
Please see the screenshots

Best regards

         shong


Uploaded Images


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#12 2007-12-11 10:22:25

tle
Member
Registered: 2007-03-19
Posts: 67

Re: Read previous row

Hi Shong,

I have made a mistake yesterday, I have used (in your example ) the context of Job test instead of it properties to get glbalMap, and I didn't have the globalMap value. But I know that I can to use context (parameter) to get gloMap value if I use tRunJob

It's Ok now, and very good.

Shong, are you cheneese (with your name) ? I am vietnameese !!!! It's more easy for me to explain in french but I think that the forum use English language !!!!

Thanks a lot for your help .

tle

Offline

#13 2007-12-12 03:26:11

minhhuy
New member
Registered: 2007-12-10
Posts: 7

Re: Read previous row

Sory everybody, i have to send a private message for tle, but this forum does not have private message function.

@tle: cậu đang làm việc ở đâu thế, có yahoo hoặc mobile ko? Tớ cũng đang làm 1 dự án với Talend, có thế liên lạc để trao đổi kinh nghiệm,
redhungpt@yahoo.com.

Thanks.

Last edited by minhhuy (2007-12-12 03:48:07)

Offline

#14 2007-12-12 03:40:13

shong
Talend team
Registered: 2007-08-29
Posts: 10297
Website

Re: Read previous row

Hi

You can send a email to him...

Feel free to post your questions on forum!

Best regards

         shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

Board footer

Powered by FluxBB