Page 1 of 1

ORA-01461: can bind a LONG value only for insert into a LONG

Posted: Wed 27 Jul 2011 14:13
by slaxman
Getting this error (ORA-01461: can bind a LONG value only for insert into a LONG) when NLS_CHARACTERSET is set to AL32UTF8 but works fine when it is WE8MSWIN1252. Insert works using direct mode when the size is 666 but fails for anything higher. In the code below, the first execute goes thru' but the 2nd one throws exception.

When I use Toad to insert, size does not seem to be a limitation. Can you help?

Code: Select all

CREATE TABLE TEST
(
  MESSAGE  NVARCHAR2(2000)
);


namespace DevartTest
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                TestNvarchar2();

            }
            catch (Exception ex)
            {               
                Console.WriteLine(ex.Message);
            }
        }

        private static void TestNvarchar2()
        {
            using (OracleConnection conn = new OracleConnection())
            {
                conn.ConnectionString = "Direct=true;server=test;port=****;SID=***;uid=***;pwd=***;";
                conn.Open();
                OracleCommand comm = conn.CreateCommand();
                OracleParameter param = comm.CreateParameter();
                param.ParameterName = "p1";
                param.OracleDbType = OracleDbType.NVarChar;
                param.SourceColumn = "MESSAGE";
                param.Size = 2000;
                comm.Parameters.Add(param);
                string cmdText = "insert into TEST(MESSAGE) values (:p1)";
                comm.CommandText = cmdText;
              
                // this works
                param.Value = new string('a', 666);
                comm.ExecuteNonQuery();

                // this fails
                param.Value = new string('b', 667);
                comm.ExecuteNonQuery();
            }
        }
    }
}

Posted: Fri 29 Jul 2011 16:06
by Shalex
We cannot reproduce the problem with dotConnect for Oracle v 6.30.196 and Oracle server v 11.1 (NLS_CHARACTERSET=AL32UTF8) using your code.

Please try using the "Unicode=true;" connection string parameter.
If this doesn't help, tell us:
a) the exact versions of your dotConnect for Oracle (x.xx.xxx) and Oracle server (xx.x);
b) NLS_LANGUAGE, NLS_CHARACTERSET, and NLS_NCHAR_CHARACTERSET of your Oracle server;
c) the regional settings of your machine: Control Panel > Reginal and Language Options > the "Standards and formats" drop-down value, Location, and Language for non-Unicode programs;
d) are you using a Latin symbol 'b' in the sample above?