Page 1 of 1

Trim not working in else clause

Posted: Mon Mar 20, 2017 2:45 pm
by pillip
Hi,

Below is what I am implemented in datastage

COALESCE(trim(field),'-1')

I am using If clause where I check for empty string and put -1 else trim the field.

If I use TrimLeadingTrailing(NulltoValue(field,-1)) I am getting an error while compilation saying that a composite call is not allowed.

Hence i am using If then else clause as below :

If TrimLeadingTraling(field)='' then -1 else TrimLeadingTrailing(field) ---

the issue with the above is that the part in the else clause is not functioning. The -1 is getting populated fine for a null but the trim part is not happening for not null fields. I have tried putting in stage variables and also used stripwhitespace and trim instead of Trimleadingtrailing. None is working.

Please advice.

Posted: Tue Mar 21, 2017 10:43 pm
by ray.wurlod
Break it up into a couple of stage variables. NullToValue() into one, then TrimLeadingTrailing() applied to the first into the next.

Posted: Wed Mar 22, 2017 6:59 am
by pillip
Thanks Ray. Actually there is a Change data capture stage after the transformer stage, the link ordering was incorrect in that because of that I was facing the trim issue. This issue got resolved, but a new issue came up.

Thanks.

Posted: Wed Mar 22, 2017 7:13 am
by chulett
Technically, this post should be closed as Resolved and a new one opened for your unrelated issue...

Posted: Wed Mar 22, 2017 8:12 am
by chulett
Thanks for that.