ORA-01461: can bind a LONG value only for insert into a LONG
Posted: 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?
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();
}
}
}
}