Page 1 of 1

Strange "rounding" issue

Posted: Fri 09 Sep 2011 10:44
by chrsadk
Hello,

I am using dotConnect for Oracle 5.0.1.0.

I'm having an issue with certain double values, when saving them to the database. For instance, when saving the double 33.36 (through a normal parameterized Oracle command), the value in Oracle after comitting is 33.359999999999992.

I know there is an accuracy aspect to doubles, but it seems odd this happens on the second digit after the separator.

The issue happens on (for instance) 29.36, 30.36, ..., 57.36.

Updating Oracle with these values through a prompt (not using dotconnect) does not have the issue.

Any idea what is causing this?

EDIT: The oracle column data type is an unconstrained NUMBER.

Best regards,
Christian Andersen

Posted: Mon 12 Sep 2011 16:36
by Shalex
I have tried the following code with dotConnect for Oracle v 6.50.214:

Code: Select all

DDL:
CREATE TABLE ALEXSH.NUMBERTABLE (
  NUMBERCOLUMN NUMBER(38, 10));

C#:
    using (OracleConnection conn = new OracleConnection()) {
        conn.ConnectionString = "Direct=true;sid=orcl1120;server=***;uid=***;pwd=***;";
        //conn.ConnectionString = "server=orcl1120;uid=***;pwd=***;";
        conn.Open();
        OracleCommand cmd = conn.CreateCommand();
        cmd.CommandText = "insert into numbertable values (:p1)";
        cmd.Parameters.Add("p1", OracleDbType.Number).Value = 33.36;
        cmd.ExecuteNonQuery();
    }
The values in Oracle in both cases (the Direct and OCI modes) are 33.36.
Please try the latest (6.50.214) version of dotConnect for Oracle. If the problem persists, send us a small test project with the corresponding DDL script.