Decimal field getting round off

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
kailas
Participant
Posts: 21
Joined: Mon Nov 17, 2008 11:49 pm
Location: bangalore

Decimal field getting round off

Post by kailas »

Hi ,

I am fetching a decimal field(10,2) as sum(skd_hrs) and loading into a fixed width sequential file as Decimal(10,2) . The problem is the value for example 89.55 is getting round of to 90.00 and so on .All the values are getting round off .Other then sum(column) i am not using any logic .

Any help is appreciated .

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

Post by chulett »

So what stages are you using in your job? And this sum() you are fetching is using a 'group by' in your source sql I assume, yes?
-craig

"You can never have too many knives" -- Logan Nine Fingers
kailas
Participant
Posts: 21
Joined: Mon Nov 17, 2008 11:49 pm
Location: bangalore

Post by kailas »

[quote="chulett"]So what stages are you using in your job? And this sum() you are fetching is using a 'group by' in your source sql I assume, yes? ...[/quote]


Stages used are DB2 Stage ,lookups ,Transformer and sequential Files.
YES I m using 'group by' in source sql
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

If you do a "view data" on the source, are the numeric values displayed correctly there?
kailas
Participant
Posts: 21
Joined: Mon Nov 17, 2008 11:49 pm
Location: bangalore

Post by kailas »

[quote="ArndW"]If you do a "view data" on the source, are the numeric values displayed correctly there

When I view the data at the source the data is showing as 98.55 but in source its getting round off like 99.00
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Is your output column to the sequential defined as Decimal(10,2) or as a string?
How about doing an explicit conversion in your transform stage using DecimaltoString() and writing a varchar to the sequential file (assuming you are currently writing a decimal field)? That explicit conversion is better than the implicit one done int he sequential file stage.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Try the following in your DB2 query

1.) Cast the result to decimal in DB2.

2.) Divide the result by 1.00

3.) Divide the result by 100 (so you will get something more than 2 decimal)
kailas
Participant
Posts: 21
Joined: Mon Nov 17, 2008 11:49 pm
Location: bangalore

Post by kailas »

Hi ,

The issue got resolved . Actually at the Data Base lavel the type is decimal(12,2) and before loading i had given decimal(10,2) so it was round offing . I gave decimal(10,2 ) everywhere and its working fine now .

Thanks everybody for your efforts .
Post Reply