To trim leading zero's in a sequential file

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
poorna.ds
Participant
Posts: 18
Joined: Sun Jun 22, 2008 3:07 am
Location: Mumbai

To trim leading zero's in a sequential file

Post by poorna.ds »

Hi All,
My job design is
ORACLE ENTERPRISE------->TRANSFORMER--------->SEQ FILE

Sequential file has 6 columns. Represented all columns as Varchar(11,2)
First two columns are string values,while rest 4 columns contain amount value. When i load the data in seq file, i need data in format for last 4 columns as eg : 2.17, 666.6, 39901.45, 2890716
But the data in o/p I get is something like below:
00000002.17, 000000666.6, 00039901.45, 000000289

My req is that i need data with trimed leading zero's.
Can anybody suggest me on this?
ulab
Participant
Posts: 56
Joined: Mon Mar 16, 2009 4:58 am
Location: bangalore
Contact:

To trim leading zero's in a sequential file

Post by ulab »

go to file properties in the target file and set the column/field properties and its values
Ulab----------------------------------------------------
help, it helps you today or Tomorrow
poorna.ds
Participant
Posts: 18
Joined: Sun Jun 22, 2008 3:07 am
Location: Mumbai

Re: To trim leading zero's in a sequential file

Post by poorna.ds »

ulab,
I guess what u are saying is the basic thing that we have to do before loading the data. But the thing is the amount column length varies. So length is mentioned as Varchar(11,2) which i have already mentioned.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

There's no such thing as Varchar(11,2). Strings don't have a scale. :?

If you need to trim something, it would make sense to use the trim() function for that, yes? It defaults to space but you can override that and you can also override the default behaviour of "all".
-craig

"You can never have too many knives" -- Logan Nine Fingers
rameshv
Participant
Posts: 11
Joined: Wed Feb 27, 2008 11:14 pm

string remove zeros

Post by rameshv »

In String how to define precision and scale.String property have precision only,You can use ltrim (input column).
poorna.ds
Participant
Posts: 18
Joined: Sun Jun 22, 2008 3:07 am
Location: Mumbai

Post by poorna.ds »

chullet: 'There's no such thing as Varchar(11,2). Strings don't have a scale.'

Here i meant to say that the metadata defined in the seq file is like :
Columnname SQLtype Length Scale
col1 varchar 11 2

I guess i should have explained it like this instead of Varchar(11,2)

Can I use trim function in sequential file?
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

You don't specify a scale for a string datatype because there is no scale, as Craig as indicated. Only when you convert it to a numeric datatype (number, decimal, float?) can you specific a scale. While it's still in a string datatype it's just a collection of character data.

Use the trim() function mentioned earlier with the appropriate option to remove leading characters, as documented in the Parallel Job Developer's Guide or on <a href=http://publib.boulder.ibm.com/infocente ... 22%20>this page</a>

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
nbalegar
Participant
Posts: 9
Joined: Fri Jul 08, 2011 2:47 am

Post by nbalegar »

Use this function it will remove the leading zeros from the column TRIM(col1,'0',L)
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Re: To trim leading zero's in a sequential file

Post by SURA »

Use CAST in SQL Query level

DS User
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Post by samsuf2002 »

If you are expecting decimal values then your source should be either decimal or numberic with given scale, then while loading into file you can convert decimal to string and trim it and also your target should be a string like varchar.
hi sam here
vinothkumar
Participant
Posts: 342
Joined: Tue Nov 04, 2008 10:38 am
Location: Chennai, India

Post by vinothkumar »

Try this
DecimalToString(ColunmName, "suppress_zero")
Post Reply