How to remove unwanted space at one column

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

dodda
Premium Member
Premium Member
Posts: 244
Joined: Tue May 29, 2007 11:31 am

How to remove unwanted space at one column

Post by dodda »

Hi all,

Iam having a source as txt file with some columns. And Target is also txt file with transformer in between

In that, iam having one column called price with data 2495.07000000 as varchar(15).

I have convert it into decimal 19 with scale 8.

I used stringtodecimal function .When i ran the job ,everything is fine.

But a single unwanted space is appended to that column .

How can remove that space .

Plz help me out.
Last edited by dodda on Sat May 17, 2008 6:58 am, edited 1 time in total.
ureddy
Premium Member
Premium Member
Posts: 36
Joined: Wed May 14, 2008 1:59 pm

Re: How to remove unwanted space at the one column

Post by ureddy »

Use either Trim(columnname) or TrimB(columnname)
Reddy
dodda
Premium Member
Premium Member
Posts: 244
Joined: Tue May 29, 2007 11:31 am

Post by dodda »

It's again showing the same space .

Can anyone give some suggestions to this one.?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

A decimal column doesn't have any spaces; just when displayed.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Isn't that just the placeholder for the sign the viewer adds?
-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 »

Yes, that is what the space in the display of view data or a peek stage is.
swapnilverma
Participant
Posts: 135
Joined: Tue Aug 14, 2007 4:27 am
Location: Mumbai

Post by swapnilverma »

ArndW wrote:A decimal column doesn't have any spaces; just when displayed. ...

trim function should be working fine...

try this trim(stringtodecimal(column -name ) )


its should work
Thanks
Swapnil

"Whenever you find whole world against you just turn around and Lead the world"
dodda
Premium Member
Premium Member
Posts: 244
Joined: Tue May 29, 2007 11:31 am

Post by dodda »

I used the trim function , But the space was not removed
Mysource column data is:::3.78875632
It is showing as " 00000000003.78875632"

Can anybody solve this one.

Your help is greatly apperciated
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Read what Arnd already told you. If the data type is decimal there IS NO SPACE in the data - only when it is displayed is there a space for the (positive) sign character. If the data type is string then you can do with it whatever you wish.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
dodda
Premium Member
Premium Member
Posts: 244
Joined: Tue May 29, 2007 11:31 am

Post by dodda »

Thanks Ray and Arnd.

Now i understand the solution.

But my testing team considered that space as a bug. They want to remove that space.

What should i do now?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Educate them. There is no space.
-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 »

It is an artifact of the decimal number being displayed. Would they object if, instead of the space, there was a "+" sign? The only way to eliminate the displayed decimal sign space is to change the data type to string (VarChar or Char) and then to use Trim() or Convert() to get rid of it.

When you are educating them, ask which part of "no space" they don't understand.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
dodda
Premium Member
Premium Member
Posts: 244
Joined: Tue May 29, 2007 11:31 am

Post by dodda »

Hi all,
My target column datatype is changed to varchar 19.
Mysource column data is::: 3.78875632
My output should be ::: 00000000003.78875632

How Can i achieve the solution fo the above one?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

Right(Str("0",19) : InLink.TheString, 19)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
fc_user
Premium Member
Premium Member
Posts: 8
Joined: Tue Feb 26, 2008 5:28 pm

Post by fc_user »

I am facing a similar kind of issue. I have to create a fixed width file, so in the sequential file I don't want any spaces before the decimal fields. i.e. if my source is 10.00, I want the output as "10.00" and not " 10.00".
I tried converting the decimal to the string and trim the space, but the moment I convert it to varchar, The result is displayed as 000.00

I also tried using this function
IF ISNULL(Read_RadiantBODDetail.Payamount1) THEN '000.00' ELSE Right(Str("0",7) : Read_RadiantBODDetail.Payamount1, 7) but the output is 000.00 only.

Can anyone suggest a possible solution to this problem?
Post Reply