The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Oracle Number precision vs. VB.NET decimal

Last post 07-22-2008, 6:11 AM by David.Parsons. 9 replies.
Sort Posts: Previous Next
  •  07-07-2008, 11:54 PM 10160

    Oracle Number precision vs. VB.NET decimal

    Hi, sorry for the new post, but I guess this is an imporant issue.

    I generated my classes with MyGeneration 1.2 and ES 2008 on an Oracle DB.

    I can't load data from several rows in the database. After some investigating it seems that the precision is too high (e.g. value = 4.12241458893984209384908234) on the Oracle side. This throws a 'Overflow' error (i thought Buffer Overflow) when the value gets loaded by .NET in the decimal field.

     

    Is there a workaround?

  •  07-08-2008, 8:57 AM 10161 in reply to 10160

    Re: Oracle Number precision vs. VB.NET decimal

    We have never had anything like this reported before, even an older architecture I created so I'm somewhat confused. Since VB and C# really use the same low level .NET types I'm more confused. But try this, in your C:\Program Files\MyGeneration\Settings there is a file named esLanguages.xml. Open it and change the mapping for your language and database to be of a different type, float or double I cannot recall the type and see if it works.

    You'll need to regenerate though ...

     


    EntitySpaces | Twitter | BLOG
  •  07-08-2008, 10:51 AM 10167 in reply to 10161

    Re: Oracle Number precision vs. VB.NET decimal

    Hi Mike

    I think the problem is that there isn't a .Net datatype that has sufficient precision - the ODP(?) provides a special datatype for use with their number fields - the only solution I saw that didn't involve using the Oracle provider was to TRUNC the field at the db side - don't know whether that's an option here?

    Cheers

    Martin

  •  07-09-2008, 12:40 AM 10175 in reply to 10161

    Re: Oracle Number precision vs. VB.NET decimal

    I think Martin is right. I've had 'problems' with my custom datalayer before. Back then I was able to solve it by using Decimal in stead of Double.. ES uses Decimal by default, so I was hoping it was a fault on my side...

    I there a way to use the ODP (Oracle Data Provider for .NET) provider? Or is this a stupid question? :-)

  •  07-09-2008, 7:21 AM 10178 in reply to 10175

    Re: Oracle Number precision vs. VB.NET decimal

    We currently only support OracleClient and not Oracle ODP provider. I'm kind of shocked the there are Oracle datatypes that cannot be stored in the core .NET data types. I will do some research on this. Can you post the exact exception text so we can do some searching on it.
    EntitySpaces | Twitter | BLOG
  •  07-09-2008, 7:31 AM 10179 in reply to 10178

    Re: Oracle Number precision vs. VB.NET decimal

    Hi Mike

     

    The link I found "useful" was: http://forums.oracle.com/forums/thread.jspa?threadID=470961&tstart=0&messageID=1682393 - you'll find another link in that thread that points to the document detailing mapping between Oracle/ODP/.Net data types – hope it helps

     

    Cheers

    Martin
  •  07-10-2008, 12:19 AM 10191 in reply to 10178

    Re: Oracle Number precision vs. VB.NET decimal

    Here's the most important part of the error:

    ---

    System.Data.OracleClient.OracleException: OCI-22053: overflow error

       at EntitySpaces.Interfaces.esDataProvider.esLoadDataTable(esDataRequest request, esProviderSignature sig)
       at EntitySpaces.Interfaces.esDynamicQuery.Load()
       at EntitySpaces.Core.esEntityCollection.LoadAll()

    ---

     

  •  07-10-2008, 1:46 PM 10205 in reply to 10191

    Re: Oracle Number precision vs. VB.NET decimal

    I found this comment:

    In .Net Framework V2.0, there is a new property on OracleDataAdapter called
    ReturnProviderSpecificTypes in which the adapter will create the DataColumn
    with OracleNumber instead of System.Decimal.  

    http://groups.google.com/group/microsoft.public.dotnet.framework.adonet/browse_thread/thread/185b831ab7a267b0/c0106784db18d83f?lnk=st&q=System.Data.OracleClient.OracleException%3A+OCI-22053%3A+overflow+error&rnum=3#c0106784db18d83f

    We will have to look in on this, any fix would have to come in a maintenance release and we'd have to be careful not to break anything on this.

     


    EntitySpaces | Twitter | BLOG
  •  07-22-2008, 12:32 AM 10318 in reply to 10205

    Re: Oracle Number precision vs. VB.NET decimal

    What should be my workaround for the moment? Is the one described below preferred?

    I cannot use:

    Code:
    Dim e as new Entity
    e.LoadByPrimaryKey(key)

    Instead I should use:

    Code:
    Dim q as new EntityQuery
    Dim e as new Entity
    
    q.SelectAllExcept(q.PreciseField)
    q.Where(q.Id.Equal(Key))
    e.Load(q)
  •  07-22-2008, 6:11 AM 10326 in reply to 10318

    Re: Oracle Number precision vs. VB.NET decimal

    I think this will give you a more complete work-around:

    Code:
    Dim q as new EntityQuery
    Dim e as new Entity
    
    q.SelectAllExcept(q.PreciseField)
    q.Select(q.PreciseField.Round(28))
    q.Where(q.Id.Equal(Key))
    e.Load(q)

    David Neal Parsons
    www.entityspaces.net
View as RSS news feed in XML