Problem with OracleGlobalization

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
bi_wolf
Posts: 2
Joined: Thu 16 Dec 2010 16:49

Problem with OracleGlobalization

Post by bi_wolf » Thu 16 Dec 2010 18:04

Hello,

I have a file with all data I have to insert in the database. For different reason my programm save the data read into a string.
Even if I use OracleGlobalization I have a problem when I have to insert numbers which they are under 1000 because in the file (so in my string) the data is 1,200.0 for 1200 :cry:
Does anabody have a solution or an idea ?

The Oracle exception is : "String format incorrect"
Thanks

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Mon 20 Dec 2010 17:04

You should set the OracleGlobalization.NumericCharacters property to the corresponding NLS_NUMERIC_CHARACTERS value. I can insert 1,200.0 in my database with the following code:

Code: Select all

//DDL:
//CREATE TABLE SCOTT.NUMBER_TABLE (
//  NUMBER_COLUMN NUMBER(38, 9));

    using (OracleConnection conn = new OracleConnection()) {
        conn.ConnectionString = "server=orcl1120;uid=scott;pwd=tiger;";

        OracleGlobalization glob = OracleGlobalization.GetApplicationInfo();
        glob.NumericCharacters = ".,";
        OracleGlobalization.SetApplicationInfo(glob);

        conn.Open();
        OracleCommand cmd = conn.CreateCommand();
        cmd.CommandText = "insert into number_table values (:p)";
        cmd.Parameters.Add("p", OracleDbType.Number).Value = "1,200.0";
        cmd.ExecuteNonQuery();
    }
Documentation:
http://www.devart.com/dotconnect/oracle ... cters.html
http://download.oracle.com/docs/cd/B283 ... ons072.htm

Notify us about the results.

bi_wolf
Posts: 2
Joined: Thu 16 Dec 2010 16:49

Post by bi_wolf » Tue 21 Dec 2010 10:57

I checked parameters of my database and NLS_NUMERIC_CHARACTERS is good :

Code: Select all

NLS_NUMERIC_CHARACTERS	.,
I used devArt.Oracle 5.70.170.0 and I test exactly your code but I have already an exception :
The input format is incorrect
I downloaded the version 6.0 and it works fine.
So all is good now.

Thanks

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 22 Dec 2010 09:54

The Devart.Data.Oracle.OracleGlobalization class manages the Oracle globalization settings of the application, and local computer (but not the server's one). I have posted the http://download.oracle.com/docs/cd/B283 ... ons072.htm reference to show the correct syntax for the OracleGlobalization.NumericCharacters property.

Post Reply