Page 1 of 1

Problem trimming a db2 char datatype value

Posted: Tue Jun 01, 2010 4:32 pm
by BradMiller
I am trying to trim a field whose datatype is char(5) in db2 database.I am setting APT_STRING_PADCHAR to "0*20".In the transformer I am trying to capture all non-nulls into 1 link and null values link into another by using proper constraint condition Len(trim(field1))=0 but everything is going into non nullable link.Could anyone please suggest me what should I do to trim those unwanted characters coming from database table.

Posted: Tue Jun 01, 2010 4:51 pm
by ray.wurlod
Why not use IsNull() in the constraint expression?

Then you can properly Trim() strings on the other link, provided that the output column is VarChar. If the output column is of type Char, then the pads will be replaced after the Trim() has been applied.

Posted: Tue Jun 01, 2010 5:25 pm
by BradMiller
Thanks Ray I tried that but its not working.I used isnotnull(field1) and isnull(field1) but still its not working and all the records are going into the not null link as unknown characters are occupied in that length of 5.And more over trim would also not work as they are unknown characters from database fixed width field.

Re: Problem trimming a db2 char datatype value

Posted: Tue Jun 01, 2010 5:55 pm
by chulett
BradMiller wrote:I am setting APT_STRING_PADCHAR to "0*20".
Surely you mean "0x20", yes? :?

Posted: Tue Jun 01, 2010 6:20 pm
by BradMiller
yes Craig

Posted: Tue Jun 01, 2010 7:51 pm
by ray.wurlod
Then you must learn what the unknown characters are, and deal with them. Could they be 0x00 characters?

Posted: Wed Jun 02, 2010 12:40 am
by sudhanmaad
Why dont you use ' STRIP(CHAR(VARIABLE NAME)) ' when you get the data from DB2 database itself , so that the trim works for you in your case

Posted: Wed Jun 02, 2010 5:15 pm
by BradMiller
I got a workaround I am using replace function while extracting from DB2 and it works.