Nulls and padding

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Nulls and padding

Post 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
Last edited by PhilHibbs on Fri Feb 04, 2005 5:17 am, edited 1 time in total.
Phil Hibbs | Capgemini
Technical Consultant
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Re: Nulls and padding

Post 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.
Phil Hibbs | Capgemini
Technical Consultant
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post 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 ??
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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]
Post Reply