Float to Numeric conversion

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
Harini
Premium Member
Premium Member
Posts: 80
Joined: Tue Mar 16, 2010 1:32 am

Float to Numeric conversion

Post by Harini »

Hello .. :)

Sorry to post a data type conversion questionn again.. I am facing quite a lot of data type conversion offlate. .

Here it is..

The source has the following data,

3.1120 (Float of length 10). How do i convert it to Numeric datatype of length 15?


Thanks a ton !
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Check DecimalToDecimal()
You are the creator of your destiny - Swami Vivekananda
Harini
Premium Member
Premium Member
Posts: 80
Joined: Tue Mar 16, 2010 1:32 am

Post by Harini »

anbu wrote:Check DecimalToDecimal()
I tried DFLOAT to Decimal conversion.. It is loading the data, but it is loading it as 10 digits after decimal, where in the input data contains only 4 digits after the decimal point.. The target column is numeric.. and the scale is 10..Is that why it is loading 10 digits??? but i am trying to populate the data whatever is coming in the input column...

any thoughts on this?
nitkuar
Participant
Posts: 46
Joined: Mon Jun 23, 2008 3:09 am

Post by nitkuar »

The target column is numeric.. and the scale is 10..Is that why it is loading 10 digits???
what is scale and precision of this field specified in target column?
Harini
Premium Member
Premium Member
Posts: 80
Joined: Tue Mar 16, 2010 1:32 am

Post by Harini »

Length : 15 ; Scale 10

Thanks
Harini
Premium Member
Premium Member
Posts: 80
Joined: Tue Mar 16, 2010 1:32 am

Post by Harini »

Harini wrote:Length : 15 ; Scale 10

Thanks
Now i have changed the source field as 'Numeric' datatype,Length to 10, Scale to 15

The target has the same datatypes and length, and scale..

When i load this i get the 3.1120000000 ( 6 zeros appended in the end) . I used Trim(columnname, "0" , "T" ) And the result is unaltered after using this function too.. Any suggesstions pls??

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

Post by ray.wurlod »

The decimal number is not stored with the trailing zeroes, it is only displayed with them. You can not get rid of them in the View Data dialog. If you want to get rid of them into a text file, declare the data type as VarChar, then Trim() will work.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Harini
Premium Member
Premium Member
Posts: 80
Joined: Tue Mar 16, 2010 1:32 am

Post by Harini »

ray.wurlod wrote:The decimal number is not stored with the trailing zeroes, it is only displayed with them. You can not get rid of them in the View Data dialog. If you want to get rid of them into a text file, declar ...
Sorry, am not a premium member yet. Still, the data is getting loaded with the zeros in the database. My target is SQL Server. By default the source column is read as 'float' .. I changed it to 'numeric' since the target column is also numeric..

Thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Harini wrote:Still, the data is getting loaded with the zeros in the database.
No, it's not. :?

As noted, that is an external representation of the internal value and the viewer is "adding" the zeroes. Trimming the zeroes is a waste of time.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Harini
Premium Member
Premium Member
Posts: 80
Joined: Tue Mar 16, 2010 1:32 am

Post by Harini »

chulett wrote:
Harini wrote:Still, the data is getting loaded with the zeros in the database.
No, it's not. :?

As noted, that is an external representation of the internal value and the viewer is "adding" the zeroes. Trimming the zeroes is a waste of time.
Thanks everybody !
Post Reply