Post a reply

Write your message and submit

Options

Click in the dark area of the image to send your post.

Go back

Topic review (newest first)

ibi2002
2011-02-11 19:50:39

Thanks John, I will review the references.

JohnGarrettMartin wrote:

the "cannot be resolved" error is because you are referencing a variable that does not exist (or is out of scope) if you are doing this in a tMap, make sure that you do in fact have a row3.TYPEUPPS in your input table.

It looks like you're struggling with basic java and ternary syntax. Please take a look at these pages to help you debug your statements:
http://download.oracle.com/javase/tutor … s/op2.html
http://www.devdaily.com/java/edu/pj/pj010018

JohnGarrettMartin
2011-02-11 19:31:59

the "cannot be resolved" error is because you are referencing a variable that does not exist (or is out of scope) if you are doing this in a tMap, make sure that you do in fact have a row3.TYPEUPPS in your input table.

It looks like you're struggling with basic java and ternary syntax. Please take a look at these pages to help you debug your statements:
http://download.oracle.com/javase/tutor … s/op2.html
http://www.devdaily.com/java/edu/pj/pj010018

ibi2002
2011-02-11 19:03:10

Here is a second scenario I am also faced with. Again I have to evaluate the values of five input columns (String and date fields) however in this case, only one column value can be TRUE for any given row, hence if that value is not null, write a string value to the one output column. This is what I wrote and it is also not working.

row2.DATEIDEASUBMITTED != null ? “Idea”
||row2.DATENOTESSUBMITTED!= null ? “Notes”
||row2.DATEPROPOSALSUBMITTED != null ? “Proposal/TOC”
||row2.DATECHAPTERSSUBMITTED!= null ? “Chapters”
||row2.TARGETMARKETAPPRAISALBYUSER != null ? “Manuscript”

ibi2002
2011-02-11 18:48:40

JohnGarrettMartin wrote:

row3.TYPETEXT == null ? null : row3.TYPETEXT || "Text"

Thanks John. Unfortunately I still get error messages and I was wondering if it is due to the fact that the input columns are Boolean. Based on what you wrote, this is the expression I now built. Bear in mind that I want to append if more than one condition is TRUE.

row3.TYPETEXT == null? null: row3.TYPETEXT || "Text"
row3.TYPESUPPS == null? null: row3.TYPESUPPS || "Supplement"
row3.TYPEMEDIA == null? null: row3.TYPEMEDIA || "Media"

I get "TYPESUPPS cannot be resolved or is not a field" and also "TYPEMEDIA cannot be resolved or is not a field"

Thanks.

JohnGarrettMartin
2011-02-11 15:27:46

row3.TYPETEXT == null ? null : row3.TYPETEXT || "Text"

ibi2002
2011-02-11 11:03:08

Thanks for your input. The input columns are 1/0 boolean values but there are also several null values, how do I handle those?

Regards,


JohnGarrettMartin wrote:

if your input columns are 1/0 boolean values, set your schema types to Boolean.

then the expression would be something like:

for output column TYPETEXT: row3.TYPETEXT || "Text"
for output column TYPEUPPS: row3.TYPEUPPS || "Supplement"
for output column TYPEMEDIA: row3.TYPEMEDIA || "Media"

JohnGarrettMartin
2011-02-11 06:04:54

if your input columns are 1/0 boolean values, set your schema types to Boolean.

then the expression would be something like:

for output column TYPETEXT: row3.TYPETEXT || "Text"
for output column TYPEUPPS: row3.TYPEUPPS || "Supplement"
for output column TYPEMEDIA: row3.TYPEMEDIA || "Media"

ibi2002
2011-02-11 04:46:16

I am new to Talend and have a requirement as follows that evaluate the Booloean value of each of the following columns and then writes a value into one output column in the Output table:

Condition 1: If TYPETEXT is true, then Row1.Output = "Text".
Condition 2: If TYPESUPPS is true, then Row1.Output "Supplement".
Condition 3: If TYPEMEDIA is true, then Row1.Output "Media"

When more than one or all the conditions are TRUE, the desired result is to have a result like this below in the output column by appending the values.

"Text","Supplement"
"Text","Supplement","Media"

And so on.

I therefore wrote the following expression below:

row3.TYPETEXT == null || row3.TYPETEXT.compareTo(BigDecimal.ZERO) == 0 ? null : row3.TYPETEXT.compareTo(BigDecimal.ONE) == 0 ? "Text" :
row3.TYPESUPPS == null || row3.TYPESUPPS.compareTo(BigDecimal.ZERO) == 0 ? null : row3.TYPESUPPS.compareTo(BigDecimal.ONE) == 0 ? "Supplement" :
row3.TYPEMEDIA == null || row3.TYPEMEDIA.compareTo(BigDecimal.ZERO) == 0 ? null : row3.TYPEMEDIA.compareTo(BigDecimal.ONE) == 0 ? "Media" :
null

However this is not giving the desired result.
Please do you have any suggestion on how to achieve this?
Thanks in advance for your help.

Regards,

Board footer

Powered by FluxBB