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

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
slaxman
Posts: 51
Joined: Wed 16 Sep 2009 20:09
Location: United States

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

Post by slaxman » Wed 27 Jul 2011 14:13

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();
            }
        }
    }
}

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

Post by Shalex » Fri 29 Jul 2011 16:06

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?

Post Reply