Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Reading unsigned 64-bit integer values from a NUMBER(20,0) column using ADO

714149Jul 27 2009 — edited Jul 28 2009
Hi,
Trying to read an unsigned 64-bit value stored in a NUMBER(20,0) column using ADO returns the wrong value.
I created a table containing a NUMERIC(20,0) column and inserted a record containing the value 1844674407370955614 for this column.
If I try to read that value using ADO I get an invalid value: 4294967294
This value seems to be a result of an overflow.
Can somebody tell me if I am doing something wrong?
Is there another way to store unsigned 64-bit values?
According to the Oracle documentation I should be able to store unsigned 64-bit integers in a NUMERIC column.
The range of an unsigned 64-bit integer is from 0 to 18,446,744,073,709,551,615.
NOTE: This seems to be a bug in the Oracle Provider for OLE DB because if I use the Microsoft OLE DB Provider for Oracle I get the right value.
I am using Oracle 10g.

The following is an example I wrote using C#

private void button1_Click(object sender, EventArgs e)
{
// database connection string
string DBConnection = "FILE NAME=C:\\OracleTest\\Oracle.udl";
// sql statment
string SQL = "SELECT LIMITS_INT64.* FROM LIMITS_INT64";
//create ADODB Connection object
ADODB.Connection Conn=new ADODB.Connection();
//create ADODB Recordset object
ADODB.Recordset rs= new ADODB.Recordset();
//create OleDb Adapter object
OleDbDataAdapter daLimits=new OleDbDataAdapter();
// finally Dataset to store returned recordset
DataSet dsLimits=new DataSet("Limits");
//open connection with the string as above
Conn.Open(DBConnection,"","",-1);
//execute the query specifying static sursor, batch optimistic locking
rs.Open(SQL,DBConnection,ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockBatchOptimistic,1);
object myObj = rs.get_Collect(3); //Here I read the value of the unsigned 64-bit interger column
//use the overloaded version of Fill method which takes recordset as parameter
daLimits.Fill(dsLimits, rs, "LIMITS_INT64");
//bind datagrid to dataset
dataGridView1.DataSource = dsLimits;
dataGridView1.DataMember = "LIMITS_INT64";
///close the connection
Conn.Close();
}



Regards.

Antonio.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 25 2009
Added on Jul 27 2009
4 comments
1,342 views