OracleNumber decimal point formatting

D

Daniel Stankiewicz

I'm connecting with an Oracle database from my .NET application, using
System.Data.OracleClient namespace. Did anybody face the problem of
formatting numbers of type System.Data.OracleClient.OracleNumber
according to a specified locale?

The method OracleNumber.ToString() doesn't take any parameters like
e.g. System.Decimal.ToString(IFormatProvider) does. I have noticed,
that formatting depends on what is put on the registry at key:
HKLM/Software/Oracle/.../NLS_LANG. But I would like to do this
programatically in a more "civilized" way than modifying registry or
enviroment variables. SQL commands similar to "alter session set
nls_territory=...." or "alter session set nls_numeric_characters=". ""
don't work, because they are concerning only current connection and one
can operate on OracleNumbers even WITHOUT database connection.

Here is sample C# code, which returns "oracle number =
1,42857142857142857142857142857142857143" for my locale (NLS_LANG in
registry is "POLISH_POLAND.EE8MSWIN1250"). I would like ToString method
to return number with a dot as decimal point....

using System;
using System.Data.OracleClient;

namespace MyOracleClient {
class OraClient {
[STAThread]
static void Main(string[] args) {
try {
OracleNumber number =
OracleNumber.One
* new OracleNumber(10)
/ new OracleNumber(7);
Console.WriteLine(
"oracle number = "
+ number);
}
catch (OracleException exc) {
Console.WriteLine(exc.Message);
}
}
}
}

Greetings
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top