One Star

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
6 REPLIES
One Star

Re: Unable to check if table exists

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
One Star

Re: Unable to check if table exists

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++;
}
One Star

Re: Unable to check if table exists

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

Regards,
Pedro
One Star

Re: Unable to check if table exists

It works perfectly!
Thanks a lot!
One Star

Re: Unable to check if table exists

Actually ++ doesn`t work for increment in Talend, I had to use Variable+=1 in stead of Variable++.
One Star bax
One Star

Re: Unable to check if table exists

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