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
Problem with OracleGlobalization
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:
Documentation:
http://www.devart.com/dotconnect/oracle ... cters.html
http://download.oracle.com/docs/cd/B283 ... ons072.htm
Notify us about the results.
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();
}
http://www.devart.com/dotconnect/oracle ... cters.html
http://download.oracle.com/docs/cd/B283 ... ons072.htm
Notify us about the results.
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 :
So all is good now.
Thanks
Code: Select all
NLS_NUMERIC_CHARACTERS .,
I downloaded the version 6.0 and it works fine.The input format is incorrect
So all is good now.
Thanks
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.