none
Problem in reading float value from oracle to Data Table RRS feed

  • Question

  • Hi,

     I am facing the same problem, when I tried to read an oracle float value through Data Reader.

    I am calling DataTable.Load(OracleDataReader object).

    It throws error of overflow. I cannot use oracle datareader separately and as it is a generic code used for MSSQL also. Also if I iterate through all the values to manually convert values then it may slow down the extraction of data.
    Friday, April 17, 2009 7:12 AM

Answers

  • Have you tried using the System.Data.OracleClient.OracleNumber type instead?  Looking at http://msdn.microsoft.com/en-us/library/yk72thhd(VS.80).aspx, using .NET Decimal types with Oracle INTEGER or NUMBER types can cause an overflow.
    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Proposed as answer by Jimmy HutsonModerator Thursday, April 23, 2009 9:36 PM
    • Marked as answer by nitin82jain Monday, July 6, 2009 2:00 PM
    • Unmarked as answer by nitin82jain Monday, July 6, 2009 2:00 PM
    • Unproposed as answer by nitin82jain Monday, July 6, 2009 2:00 PM
    • Marked as answer by nitin82jain Monday, July 6, 2009 2:00 PM
    Thursday, April 23, 2009 9:36 PM
    Moderator
  • It is not just the rounding. Decimal and Float types may have complitely different internal size and are not completely compatible. What you would need to do in your case is to read value in the reader as decimal (if it is defined as decimal in database) or float (if it is float)
    Val Mazur (MVP) http://www.xporttools.net
    • Marked as answer by nitin82jain Monday, July 6, 2009 2:02 PM
    Friday, April 24, 2009 10:18 AM
    Moderator

All replies

  • Even if you use it with MS SQL successfully does not mean that you have matching datatypes defined in Oracle table(s). To me error means you have incorrectly defined datatype(s) for some of the column(s) in DataTable. For example if DataTable has column of Single type and you load double-precision numbers from the database, you would expect this type of message. I would suggest to review definition of the datatypes in your DataTable and see if they are good enough to accomodate values from the database.
    Val Mazur (MVP) http://www.xporttools.net
    Friday, April 17, 2009 10:02 AM
    Moderator
  • Hi,

    The column type is decimal which i get through GetSchema function and the value it tries to insert is of type float.

    Is there any way of checking or rounding value before inserting it in datatable.

    Even when the GetValue function of DataReader called it throws error if the value is greater than decimal max
    • Marked as answer by nitin82jain Wednesday, April 22, 2009 8:56 AM
    • Unmarked as answer by nitin82jain Wednesday, April 22, 2009 8:56 AM
    Friday, April 17, 2009 10:08 AM
  • Have you tried using the System.Data.OracleClient.OracleNumber type instead?  Looking at http://msdn.microsoft.com/en-us/library/yk72thhd(VS.80).aspx, using .NET Decimal types with Oracle INTEGER or NUMBER types can cause an overflow.
    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Proposed as answer by Jimmy HutsonModerator Thursday, April 23, 2009 9:36 PM
    • Marked as answer by nitin82jain Monday, July 6, 2009 2:00 PM
    • Unmarked as answer by nitin82jain Monday, July 6, 2009 2:00 PM
    • Unproposed as answer by nitin82jain Monday, July 6, 2009 2:00 PM
    • Marked as answer by nitin82jain Monday, July 6, 2009 2:00 PM
    Thursday, April 23, 2009 9:36 PM
    Moderator
  • It is not just the rounding. Decimal and Float types may have complitely different internal size and are not completely compatible. What you would need to do in your case is to read value in the reader as decimal (if it is defined as decimal in database) or float (if it is float)
    Val Mazur (MVP) http://www.xporttools.net
    • Marked as answer by nitin82jain Monday, July 6, 2009 2:02 PM
    Friday, April 24, 2009 10:18 AM
    Moderator
  • Hi,

    "read value in the reader as decimal (if it is defined as decimal in database) or float (if it is float) ".

    How to read value specific to type in reader?

    Monday, April 27, 2009 7:15 AM
  • Reader has overloaded methods that start with Get... names. Use appropriate method fo each specific type.
    Val Mazur (MVP) http://www.xporttools.net
    Monday, April 27, 2009 10:13 AM
    Moderator