Usage of IF Statement

In the reformat component, I have created a expression as follows. But its giving a syntax error.

if isnull($in.0.ID) $in.0.ACCOUNT_NAME else $in.0.BILLING_CITY

Could you please let me know how to use the if statement correctly.

Thanks & Regards,
Akhil

Hi Akhil,

please take a look on http://doc.cloveretl.com/documentation/ … -ctl2.html and http://doc.cloveretl.com/documentation/ … -ctl2.html

In your case:

if (isnull($in.0.ID)) $in.0.ACCOUNT_NAME; else $in.0.BILLING_CITY;

should work. I added round brackets around condition and add semicolons for each statement. Also, you are probably missing left side of statements. So it should be something like:

if (isnull($in.0.ID)) $out.0.MY_FIELD = $in.0.ACCOUNT_NAME; else $out.0.MY_FIELD = $in.0.BILLING_CITY;

Or shorter:

$out.0.MY_FIELD = isnull($in.0.ID) ? $in.0.ACCOUNT_NAME : $in.0.BILLING_CITY;

I hope this helps.

Thanks Jaroslav.

Thanks & Regards,
Akhil