Page 1 of 1

Nulls and padding

Posted: Fri Feb 04, 2005 4:40 am
by PhilHibbs
I have this field derivation:

IF IsNull(Lookup_OrderLine.HOIPDNO) THEN "  " ELSE FMT(Lookup_OrderLine.HOIPDNO[1,2],"2 L") : IF IsNull(Lookup_MinBX65.BX65TPUR) THEN "  " ELSE FMT(Lookup_MinBX65.BX65TPUR[1,2],"2 L")

I was expecting that this would always produce a four-character string. However, if the values are null, it produces a string of two spaces. Any idea why?

I think the values are null because when I map the above and then the two input two fields to a csv sequential file, I get this:

"PK ","PK","     "
"  ",,

Update: put   in to stop the spaces being compressed

Re: Nulls and padding

Posted: Fri Feb 04, 2005 4:51 am
by PhilHibbs
Got it, I think the second IF is being treated as part of the ELSE clause. I will break it up into stage variables.

Posted: Fri Feb 04, 2005 4:58 am
by Sainath.Srinivasan
That is because you have only one space within the double quotes.

Or is it just that the 2 spaces or trimmed in this forum display ??

Posted: Fri Feb 04, 2005 5:03 am
by ArndW
Hello Phil,
IF IsNull(Lookup_OrderLine.HOIPDNO) THEN " " ELSE FMT(Lookup_OrderLine.HOIPDNO[1,2],"2 L") : IF IsNull(Lookup_MinBX65.BX65TPUR) THEN " " ELSE FMT(Lookup_MinBX65.BX65TPUR[1,2],"2 L")
You guessed it; the statement doesn't parse the way you wish when written that way, you can add parenthesis to make it work, along the lines of

Code: Select all

(IF Cond1 THEN 'a' ELSE 'b') : (IF Cond2 THEN 'c' ELSE 'd')
will work.

[/code]