Suppressing leading Zero's of Decimal Data type

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
bensonian
Participant
Posts: 42
Joined: Tue Nov 22, 2005 2:12 pm

Suppressing leading Zero's of Decimal Data type

Post by bensonian »

I was wondering if there is a function that could drop all the leading zeros off of a Decimal data type.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

A decimal data type doesn't have leading zeroes.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

When? When writing to a sequential file? When loading into a database? Why do you have a problem with leading zeroes? Is the Peek stage confusing you?[/url]
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
bensonian
Participant
Posts: 42
Joined: Tue Nov 22, 2005 2:12 pm

Post by bensonian »

Actually i was doing a division operator on a varchar data type and even used type conversion function to change it to decimal data type. StringtoDecimal(). Still in the sequential file i could see leading zeroes. My decimal data type is of length 12 scale 8.
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

bensonian wrote:Actually i was doing a division operator on a varchar data type and even used type conversion function to change it to decimal data type. StringtoDecimal(). Still in the sequential file i could see leading zeroes. My decimal data type is of length 12 scale 8.
yes the decimal data type ammends leading and trailing 0 to fit the exact length as you specify

but while writing it to Database it is removed


but when you write it to sequential file leading and trailing zeros will be there
but that will not make any difference while performing calculations

Since float and double doesn't ammends leading and trailing 0

You may convert the output to float or double from decimal


Just a suggestion, You may find some other way also.

Regards,
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
Post Reply