One Star

Relational.ISNULL() fails

Hey,
i want to check the content of Field in a tmap, used as a counter...
If the return of the row is null (=does not exist), i want to set the value 0 for the new row (=INSERT of ROW).
If the the return of the row has a content (>=0), I want to increase the value with 1 (=TIMES of UPDATE)
Field definition: BigDecimal(22,0)
the formula should look like this:
Relational.ISNULL(row6.COUNTING)?0:row6.COUNTING+1
But i get an error in the Test-tool of the Expression Builder, regardless of the used Test-value:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:

The same with a Date:
Like: IF the DATEFIELD IS NULL then gimme sysdate else use DATEFILED
Relational.ISNULL(row6.DATEFIELD)?TalendDate.getCurrentDate():row6.DATEFILED

What is wrong with the two statements? Please help (I am new in Java, only DB-Developer)...
6 REPLIES
One Star

Re: Relational.ISNULL() fails

It is probably a problem with the test tool. I've found it happens a lot. Try running the job or click the code tab to see if there are any errors.
One Star

Re: Relational.ISNULL() fails

Hi,
You can use following expression to increment your count.
row1.COUNTING == null || row1.COUNTING == 0 ? 0 : row1.COUNTING + 1
Please provide us the date format sample, and the information that whether the date is contained in "String" or "Date" Field.
--
Regards,
Vinod
One Star

Re: Relational.ISNULL() fails

Hi,
Ideally expression row1.DATEFILED == null ? TalendDate.getCurrentDate() : DATEFILED should work, however at my end it is not able to parse any provided date in any format using tFixedFlowInput/tFileInputDelimited component, try same with your job, but if it does not work you can make use of the below mentioned expression
row1.DATEFILEDisEmpty() || row1.DATEFILED.toString() == null ? TalendDate.getCurrentDate().toString() : DATEFILED
Later returned string can be parsed to retrieve Date, using tExtractRegexFields or tConvertType.
--
Regards,
Vinod
One Star

Re: Relational.ISNULL() fails

Date format expression for string "Fri Aug 31 17:45:53 GMT+05:30 2012"
--------------------------
TalendDate.parseDate("MMM dd yyyy", Var.var1.substring(4,10).concat(Var.var1.substring(29, 34)))

--
Regards,
Vinod
One Star

Re: Relational.ISNULL() fails

I'm using Talend 5.4.2 and I'm facing the same issue that mpmarky had faced. I understand the alternative way that vinod_talend has provided but I want to know how to use Relational.ISNULL() function for the task that mpmarky tried to do. Is there anyone from the Talend product team that can help us with this ?
One Star

Re: Relational.ISNULL() fails

It's : "Relational.ISNULL(row1.myDate)?TalendDate.getCurrentDate():row1.myDate"
(If myDate is NULL then myDate = Today else myDate=myDate )
I just tested it, and it's working.