How to remove additional zeros in a record using Transformer

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
ssunda6
Participant
Posts: 91
Joined: Tue Sep 19, 2006 9:32 pm

How to remove additional zeros in a record using Transformer

Post by ssunda6 »

Hi all,
i want to remove additional zeros from records using a transformer. I have tried with Trim function but it is not working .Also, please give the format in which this has to be done.
Kirtikumar
Participant
Posts: 437
Joined: Fri Oct 15, 2004 6:13 am
Location: Pune, India

Post by Kirtikumar »

Whats your datatype for which you are trying to remove leading zeros?

If it decimal, then after removal, you will have to carry it as char or varchar or int. Because, in PX decimal are always have leading zeros when they are stored in datasets or carried through links (i.e. virtual datasets).

If your input is decimal and then use DecimalToString(InCol, 'supress zero')

If the in col is string, then a normal trim should work.

May be some special handling for first char of the col, will be needed as it will be sign char.
Regards,
S. Kirtikumar.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

How precisely have you specified your Trim() function?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
keshav0307
Premium Member
Premium Member
Posts: 783
Joined: Mon Jan 16, 2006 10:17 pm
Location: Sydney, Australia

Post by keshav0307 »

Please give more details about the problem, like what is the input datatype, what is output datatype etc. Because there are many ways you can handle it.
ssunda6
Participant
Posts: 91
Joined: Tue Sep 19, 2006 9:32 pm

Post by ssunda6 »

ray.wurlod wrote:How precisely have you specified your Trim() function? ...

Hi,
I have tried with Trim function Trim("columnname","0","L") but this is not working.The data type is Char in input and output.Let me know if there is any other format which i need to give.With the above function used I am getting junked data in the output.Also i have tried various other formats of trim.
Lucky
Participant
Posts: 31
Joined: Mon Oct 10, 2005 11:05 pm

Post by Lucky »

Hi,

As far as I know Trim function works for Varchar data type. You cannot use Trim for fields which are of Char data type.

Please correct me if I am wrong.
Kirtikumar
Participant
Posts: 437
Joined: Fri Oct 15, 2004 6:13 am
Location: Pune, India

Post by Kirtikumar »

As I am from server bkg, my understaning is it works for all.

I creates a job with char (5) having leading zeros and then tried trim on it.

It is giving proper results i.e. 00005 is converted to "5 " value after using trim.

So I feel there is no such restriction.
Regards,
S. Kirtikumar.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Lucky wrote:...As far as I know Trim function works for Varchar data type. You cannot use Trim for fields which are of Char data type...
You can use the TRIM() function on CHAR, but since the resultant output if of fixed length it will automatically pad the output according to string rules. You can use it to replace/remove zeroes.,
pankajg
Participant
Posts: 39
Joined: Mon Jun 05, 2006 5:24 am
Location: India

Post by pankajg »

Using the trim function as you have mentioned
Trim("columnname","0","L")
would only remove the leading zeros from the "columnname" specified.

You need to be clear if you would want to remove leading 0 or trailing 0 or anything in betn as well..

Using option "A" Removes all occurrences of character
"B" Removes leading and trailing occurrences of character.
"T" Removes trailing occurrences of character.

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

Post by ray.wurlod »

The OP has begun a new thread here on this topic.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
michaeld
Premium Member
Premium Member
Posts: 88
Joined: Tue Apr 04, 2006 8:42 am
Location: Toronto, Canada

Post by michaeld »

This will do it:

DecimalToString(ColumnName),"fix_zero,suppress_zero")


NOTE: One of the previous posters spelled suppress with one p.
Mike
AaronVG
Participant
Posts: 13
Joined: Thu Feb 15, 2007 4:02 pm

Post by AaronVG »

Lucky wrote:Hi,

As far as I know Trim function works for Varchar data type. You cannot use Trim for fields which are of Char data type.

Please correct me if I am wrong.
I am not sure, but I will say that I was experiencing a challenge with a Lookup Stage as my input was Char and lookup reference was VarChar. Once I converted Char to VarChar (Transform Stage) it worked.
<<<>>>
My opinions are just that.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

:idea: With a Modify stage it might work even faster. You will still need a string_trim function, however. Refer to Orchestrate Operators guide for more information, as they seem to have left this function out of the Parallel Job Developer's Guide. This document may also prove useful.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply