Hello Laurent,

unfortunately, the scale (2 digits) is not present in the result of the SUM
method of the database, 

 - the method getScale returns 0, as it cannot determine the 
   precision

 - the method getBigDecimal() returns a big decimal that will contain at least all
   significant digits, and does not loose any.
 
The only legal option (from the JDBC standard)
would be to throw an SQLException for all cases where an exact scale 
cannot be determined. We will consider this, and look whether
this causes more harm than benefits, and decide whether it would be good to
change it or not. You should note that the 'getBigDecimal(index, scale)' method
is deprecated, and for columns the scale can be determined, it is correctly
set in the big decimal retrieved with the normal getBigDecimal method.

Anyway (for any database), it happens often that not all meta data information
that is available for a single column, is available for a column of a result,
especially if it originates from some computation.

Sorry for any inconvenience

Regards

Alexander Schr�der
SAP Labs Berlin

> -----Original Message-----
> From: Laurent Vaills [mailto:laurent.vaills@;dms.at]
> Sent: Thursday, October 17, 2002 3:32 PM
> To: [EMAIL PROTECTED]
> Subject: possible bug with SUM on FIXED column (dbmcli and 
> JDBC Driver)
> 
> 
> Hi.
> 
> It seems I have found a bug with the FIXED column.
> I am using SapDB 7.3.0.25 on RedHat 7.3.
> 
> I have created this table :
> CREATE TABLE Test (
>   ID INT NOT NULL,
>   Amount FIXED(10, 2) NOT NULL
> )
> 
> INSERT INTO Test VALUES (1, 5.5);
> INSERT INTO Test VALUES (1, 4.3);
> INSERT INTO Test VALUES (2, 4.3);
> INSERT INTO Test VALUES (2, 2.45);
> 
> 1 / In dbmcli :
> dbmcli on KASSA>sql_execute SELECT ID, SUM(Amount) FROM Test 
> GROUP BY ID
> OK
> END     
> 1;9
> 2;6
> 
> The sum is not correct. It should be 9.80 and 6.75
> 
> 2 / I tried with the JDBC driver (7.3.0.29a) I got :
> 9.80000000000000000000000000000000000000
> 6.75000000000000000000000000000000000000
> which is not correct (the scale should be 2).
> If I tried to get the scale from the metadata I got 0 !!!
> I attached the Java file.
> 
> Laurent
> 
> 
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to