Reading a VARRAY causes an exception

Reading a VARRAY causes an exception

Postby chaosworrier » Sat 20 Nov 2004 13:56

I am using V2.40 of OraDirect .NET.

I have some code which reads rows from a table where some of the columns are embedded VARRAY(3) OF NUMBER.

Things all work fine until I read in a row where one of these numbers in the VARRAY is

-6.046E-17

Then I get:

System.ArgumentOutOfRangeException

Specified argument was out of the range of valid values.

I get a similar erorr if I do some (more convoluted) code in Oracle's ODP.Net to read in the value.

What gives? I know that numbers close to zero sometimes get slightly altered to to the inaccurate way of storing decimals in binary representation, but I figured that being a generic number would prevent this issue.

I had this issue near the beginning of the year and was informed by Core Labs that there would be a solution in the next release.

Well, I moved on to other projects so left it alone until now; there has been at least one release of OraDirect .NET since then but the issue does not seem resolved...

Any ideas on a work-around or solution? I cannot really change the underlying data in the Oracle database as it is derived from a source which is oiut of my control.

Thanks in advance,
Paul.

PS: Of course, my client now wants an immediate solution!
chaosworrier
 

Re: Reading a VARRAY causes an exception

Postby Oleg » Mon 22 Nov 2004 10:42

We tried to reproduce the problem in the following way:

Created a table

create table num2 (
n tnumbers
)

where tnumbers is VARRAY(3) OF NUMBER

Inserted a record into the table:

insert into num2 values (tnumbers(-6.046E-17,-6.046E-17,-6.046E-17))

Read a value using the next code sample:

Code: Select all
OracleConnection conn = new OracleConnection();
OracleCommand cmd = new OracleCommand();
conn.ConnectionString = "User Id=scott;Password=tiger;Server=ora;";
cmd.CommandText = "select * from num2";
cmd.Connection = conn;
conn.Open();
OracleDataReader rd = cmd.ExecuteReader();
rd.Read();
OracleArray arr = rd.GetOracleArray(0);
if (arr != null) {
Console.WriteLine(arr[0]);
}


And received a correct result.
Oleg
Devart Team
 
Posts: 264
Joined: Thu 28 Oct 2004 13:56


Return to dotConnect for Oracle