Rounding and decimals

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
peterbaun
Premium Member
Premium Member
Posts: 93
Joined: Thu Jul 10, 2003 5:27 am
Location: Denmark
Contact:

Rounding and decimals

Post by peterbaun »

Hi -

Is the following expected -

Job :
src --> xfm --> db2

In the xfm 2 decimal numbers are divided in a stage variable and the result put in a target field defined as a decimal(15,4) which then is inserted into the db2/as400 database where the field also is defined as decimal(15,4).

In version 5.2 there is no problem with this, the job runs without errors/warnings -
Eg.
var1 = 23.3150
var2 = 30.0000
In the stagevariable : var1 / var 2
Then the result inserted into the db2 database is 0.7772

In 7.5.1 I get a warning :
SaOrLiStockDayTest..xfm: The column data has been truncated to '0.77716666666666'.

The data is inserted into the database as 0.7772 but it is not good since we get a lot of warnings (hence the job aborts!).

I am aware that in the transformer the value internally is represented as 0.777166666666667 but the question is, is this expected behaviour in version 7.5.1 - compared with 5.2 ?

It is easily solved by using the function NumericRound4(), but I would like to avoid this solution since it then has to be implemented a lot of places.

Thx

/Peter
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

I have seen it when we cross the barrier from DS 5 to 6. V 5.x does not bother much about the datatype but V 6.x expects the data to comply with the metadata more strictly.
jseclen
Participant
Posts: 133
Joined: Wed Mar 05, 2003 4:19 pm
Location: Lima - Peru. Sudamerica
Contact:

Re: Rounding and decimals

Post by jseclen »

Hi Peter

Use the next data stage function

Formato = "R": Num_Decimals
Ans = FMT(Number, Formato)

In your case set the next values

Formato = 'R4'
Ans = FMT(0.77716666666667,'R4')

The result is 0.7772

I hope this help
Saludos,

Miguel Seclén
Lima - Peru
Post Reply