how to safely map an Oracle NUMBER to a C#.NET decimal
425313Aug 10 2004 — edited Aug 23 2004All--
Please help.
I saw a site on Oracle datatypes at http://www.ss64.com/orasyntax/datatypes.html and found it interesting.
The problem that I face is that I need to map Oracle datatypes to DotNet datatypes and, unfortunately, DotNet does not provide a numeric datatype large enough to hold all possible values for NUMBER. So, I must restrict the column datatypes in Oracle to be NUMBER(p,s) where p and s are within the capabilities of a DotNet decimal.
If you can help with this, please read on.
From http://www.ss64.com/orasyntax/datatypes.html we know that in Oracle 9...
"
NUMBER(p,s)
The precision p can range from 1 to 38.
The scale s can range from -84 to 127.
"
...and from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html/vclrfcsharpspec_5_3.asp
we know of the decimal datatype in C#.NET the following...
"
The decimal type is a 128-bit data type suitable for financial and monetary calculations. The decimal type can represent values ranging from 1.0 × 10?28 to approximately 7.9 × 1028 with 28-29 significant digits
"
...so, the question is...
How does one declare an Oracle NUMBER(p,s) so that it will not overflow the C#.NET datatype?
I think it would be...
NUMBER(28, s)
...but I am not sure what s would be.
What is the answer here?
Please advise.
Thank you.
--Mark