How to remove the padding charachers from a string

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
Billyqing
Participant
Posts: 44
Joined: Thu May 13, 2004 12:00 pm
Location: Canada

How to remove the padding charachers from a string

Post by Billyqing »

Does any one know how to remove the padding charactors like 0x0 from a string?

Thanks in advance
Bill
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

If coming from source, Trim is what you need. Else check Padchar in environment variables.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
Billyqing
Participant
Posts: 44
Joined: Thu May 13, 2004 12:00 pm
Location: Canada

Post by Billyqing »

I have tried all TRIM functions but none of them works.
Bill
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

It probably works fine but then they get added right back on. How about more details about what exactly you are doing where and what the end result is you are trying to achieve?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

In particular, what data types are involved?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Remember that CHAR fields aren't trimmed, a Char(5) string with "hi " is still "hi " after TRIMming.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Remember that without code tags the forum software removes all of that nasty extra white-space you accidentally put in there. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There are ways of getting "hi___" to work without code tags, if you really want to.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I know, it was just a friendly poke in the kidneys for Petty Officer Wussing. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I stand corrected and am appropriately

Code: Select all

"chastised     "
parag.s.27
Participant
Posts: 221
Joined: Fri Feb 17, 2006 3:38 am
Location: India
Contact:

Post by parag.s.27 »

chulett wrote:It probably works fine but then they get added right back on. How about more details about what exactly you are doing where and what the end result is you are trying to achieve? ...
We had similar problems in our case where a Char(0) characted is getting appended at the end of the string. Even though the Trim function is applied in the source extraction query or the transformer after that then also it is not getting removed.

Then we tried a weird solution. Initially extract the data and put it in a Dataset. Then we read the dataset and applied function

Code: Select all

Trim(<Col name>,Char(0),'A')
. This resolved our problem and that special character never returned in the data.
Thanks & Regards
Parag Saundattikar
Certified for Infosphere DataStage v8.0
Billyqing
Participant
Posts: 44
Joined: Thu May 13, 2004 12:00 pm
Location: Canada

Post by Billyqing »

Hi Everyone,

Thanks for all valuable inputs.
This issue has been solved now.

The details that we did here are:

The source data field is Varchar. The target file we produced is defined as Char field. The Char(0) charactor was padded in the ETL processes because the Environment Variable used for padding defaults as Char(0). I had tried to use Trim function but it would not work. All we did is to change Char fields to Varchar in the ETL processes. It works now but spenting a lot of time.

Code:
Trim(<Col name>,Char(0),'A')
This code is very good. I will try to use this if the problem comes again.
Bill
Post Reply