Transformer trim question

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
dscon9128
Participant
Posts: 25
Joined: Fri Jun 13, 2008 9:11 am

Transformer trim question

Post by dscon9128 »

What happens when you trim('') as opposed to trim (' '), that is trim of a field without a space, and trim of a field with just a single space . I believe trim removes trailing and leading spaces, but what if i want to have just a single space intact? Will trimming remove the single space as well?
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Re: Transformer trim question

Post by priyadarshikunal »

dscon9128 wrote:What happens when you trim('') as opposed to trim (' '), that is trim of a field without a space, and trim of a field with just a single space . I believe trim removes trailing and leading spaces, but what if i want to have just a single space intact? Will trimming remove the single space as well?
single space from where? between to words or leading or trailing?

look for the different options of trim function (Basic Reference Guide), I think D and R are suitable options if you want only redundant characters to be removed.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The default behaviour of Trim() is to remove leading, trailing and redundant consecutive trimmable characters. Therefore Trim(" ") would leave a single space character as the result.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
dscon9128
Participant
Posts: 25
Joined: Fri Jun 13, 2008 9:11 am

Post by dscon9128 »

ray.wurlod wrote:The default behaviour of Trim() is to remove leading, trailing and redundant consecutive trimmable characters. Therefore Trim(" ") would leave a single space character as the result. ...
Thanks a lot to both of you for your response. Basically , to restate my exact requirement, i need to trim all the fields on incoming data, before sending the data to an xml output stage. I achieve the trimming by means of using a transformer. However, some fields have a single space as the value.It is important that i maintain that single space,and hence i was just wondering if the trim function would eliminate the single space as well.
So if i understand Ray's response , trim of a single space should preserve the space intact. i.e trim(" ") =" ".

Thanks again!
Uday
Post Reply