Problem trimming a db2 char datatype value

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
BradMiller
Premium Member
Premium Member
Posts: 87
Joined: Mon Feb 18, 2008 3:58 pm
Location: Sacramento, CA

Problem trimming a db2 char datatype value

Post 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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
BradMiller
Premium Member
Premium Member
Posts: 87
Joined: Mon Feb 18, 2008 3:58 pm
Location: Sacramento, CA

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: Problem trimming a db2 char datatype value

Post by chulett »

BradMiller wrote:I am setting APT_STRING_PADCHAR to "0*20".
Surely you mean "0x20", yes? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
BradMiller
Premium Member
Premium Member
Posts: 87
Joined: Mon Feb 18, 2008 3:58 pm
Location: Sacramento, CA

Post by BradMiller »

yes Craig
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Then you must learn what the unknown characters are, and deal with them. Could they be 0x00 characters?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sudhanmaad
Participant
Posts: 3
Joined: Tue Jan 12, 2010 10:52 pm
Location: chennai

Post 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
BradMiller
Premium Member
Premium Member
Posts: 87
Joined: Mon Feb 18, 2008 3:58 pm
Location: Sacramento, CA

Post by BradMiller »

I got a workaround I am using replace function while extracting from DB2 and it works.
Post Reply