Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Unable to check if table exists

Hello,
I am new to Talend and I would like to create a job that checks if a table exists in Postgres, and if it does retrieve a certain max() value and place it in a variable X, if it doesn`t set the X variable to 0.
Could someone please help me out?
Thank you,
Andras
Labels (2)
6 Replies
Anonymous
Not applicable
Author

Hi Andras
Welcome to Talend Community!
According to your requirement, you can create job as follows. If this is the first time using TOS, maybe it's a little complex.
tPostgreSQLInput-->main-->tJavaRow
|
OnSubjobError
|
tJava

Regards,
Pedro
Anonymous
Not applicable
Author

Thank you for your answer.
Instead of using tJava can I do this If/Else in tMap? I know that tMap does not support If/Else, but is there a way of coding the tMap to do a check like:
if(row1.X==null){
row1.X = 1;
} else{
row1.X++;
}
Anonymous
Not applicable
Author

Hi
Try this expression.
row1.X==null?1;row1.X++

Regards,
Pedro
Anonymous
Not applicable
Author

It works perfectly!
Thanks a lot!
Anonymous
Not applicable
Author

Actually ++ doesn`t work for increment in Talend, I had to use Variable+=1 in stead of Variable++.
Anonymous
Not applicable
Author

I guess it works, it's just the post increment effect, use ++X (pre increment)