Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
ksrikanthr
Contributor
Contributor

Conditional expression causing errors when not enclosed in opening and closing braces

I've the following in tDBInput (Amazon Redshift) -

"select ln_id, ln_typ from ln_table where 1=1" +

(

(context.load_type).equalsIgnoreCase("HISTORY") ? "" : (" and aqsn_dt <= rec_cren_dttm")

)

If I do not have the beginning and ending braces after the + sign as shown above, then I get an error in Talend saying - Type mismatch: cannot convert from String to boolean. What is the need of putting the braces around the whole conditional expression?

Labels (4)
1 Reply
Anonymous
Not applicable

Hi

The query filed does not support ternary expression, you can define the query on a tJava before tDBInput, eg:

tJava

|onsubjobok

tDBInput--main...>

 

on tJava:

if((context.load_type).equalsIgnoreCase("HISTORY")){

context.query="select ln_id, ln_typ from ln_table where 1=1";

}else{

context.query="select ln_id, ln_typ from ln_table where 1=1 and aqsn_dt <= rec_cren_dttm";

}

 

In the Query field of tDBInput, set the query as: context.query

Regards

Shong