Page 1 of 1
Problem with OracleGlobalization
Posted: Thu 16 Dec 2010 18:04
by bi_wolf
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
Does anabody have a solution or an idea ?
The Oracle exception is : "String format incorrect"
Thanks
Posted: Mon 20 Dec 2010 17:04
by Shalex
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.
Posted: Tue 21 Dec 2010 10:57
by bi_wolf
I checked parameters of my database and NLS_NUMERIC_CHARACTERS is good :
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
Posted: Wed 22 Dec 2010 09:54
by Shalex
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.