Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v5.2
  HXTT Cobol v2.1
  HXTT DBF v5.2
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Excel v4.2
  HXTT Paradox v5.2
  HXTT Text(CSV) v5.2
  HXTT XML v1.2
Offshore Outsourcing
Oracle Data Import/Export
DB2 Data Import/Export
Sybase Data Import/Export
Free Resources
  Firewall Tunneling
  Search Indexing Robot
  Conditional Compilation
  Password Recovery for MS Access
  Password Recovery for Corel Paradox
  Checksum Tool for MD5
  Character Set Converter
  Pyramid - Poker of ZYH
   
   
   
Hongxin Technology & Trade Ltd. of Xiangtan City (abbr, HXTT)

HXTT DBF
Precision Lost
Fernando Hartmann
2008-12-10 11:13:00.0


We have a strange problem happening here, if We execute the following command using the last version available o HXTT

SELECT sum(F8)/sum(F5) as VAL, f4 FROM tablex WHERE F4 = 'ROGER VARGAS' group by f4

We get the following response

1.0303073128547828

With the following command (same but without the group by)

SELECT sum(F8)/sum(F5) as VAL FROM tablex WHERE F4 = 'ROGER VARGAS'

We get the following result

1.03


The precision of the division was lost !

The structure of the DBF is

F4 Character 20 Asc Machine Yes
F5 Numeric 15 2 Yes
F8 Numeric 12 2 Yes


You can see the problem running the following code

package javaapplication1;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.ParseException;

public class RoundError {

public static void execute(String label, Connection con, String sql) throws SQLException, ParseException {
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
System.out.println("\n"+label+"\n--------------------------------------------------------------");
for (int i = 0; i < rs.getMetaData().getColumnCount(); i++) {
System.out.print(rs.getMetaData().getColumnName(i + 1) + "(" + rs.getMetaData().getColumnTypeName(i + 1) + ")\t");
}
System.out.println("\n--------------------------------------------------------------");
while (rs.next()) {
for (int i = 0; i < rs.getMetaData().getColumnCount(); i++) {
System.out.print(rs.getObject(i+1)+"\t");
}
System.out.println("");
}
System.out.println("--------------------------------------------------------------");
stmt.close();
}

public static void main(String[] args) throws Exception {
String connectionUrl;
Connection con;
connectionUrl = "jdbc:DBF:/C:/temp";
Class.forName("com.hxtt.sql.dbf.DBFDriver");
con = DriverManager.getConnection(connectionUrl);
String sql = "SELECT sum(F8)/sum(F5) as VAL FROM tablex WHERE F4 = 'ROGER VARGAS'";
execute("without group by", con, sql);
sql = "SELECT sum(F8)/sum(F5) as VAL, f4 FROM tablex WHERE F4 = 'ROGER VARGAS' group by f4";
execute("with group by", con, sql);
con.close();
}
}




The result is


without group by
--------------------------------------------------------------
VAL(DOUBLE)
--------------------------------------------------------------
1.03
--------------------------------------------------------------

with group by
--------------------------------------------------------------
VAL(DOUBLE) F4(VARCHAR)
--------------------------------------------------------------
1.0303073128547828 ROGER VARGAS
--------------------------------------------------------------


Thanks for your attention













Re:Precision Lost
HXTT Support
2008-12-11 01:30:59.0
Checked. That was resulted by using the column precision information. Fixed. Please download the latest package. Thanks.
Re:Re:Precision Lost
Fernando Hartmann
2008-12-11 08:53:30.0
Just tried the new version, and now its work right.
Thanks for your quick help.

Search Key   Search by Last 50 Questions




Google
 

Address: 9 Station Rd., Xiangtan City, Hunan Province, P.R. China
Postcode: 411100
Phone: (86)731-58225727
Fax: (86)731-58225727
Email: webmaster@hxtt.com
Copyright © 1999-2011 Hongxin Technology & Trade Ltd. | All Rights Reserved. | Privacy | Legal | Sitemap