ORA-01461: can bind a LONG value only for insert into a LONG column-Occurs when querying

前端 未结 15 1760
野的像风
野的像风 2020-11-30 02:44

When I try to query objects, I end up with following error:

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

Could someo

15条回答
  •  北海茫月
    2020-11-30 03:24

    A collegue of me and I found out the following:

    When we use the Microsoft .NET Oracle driver to connect to an oracle Database (System.Data.OracleClient.OracleConnection)

    And we are trying to insert a string with a length between 2000 and 4000 characters into an CLOB or NCLOB field using a database-parameter

    oraCommand.CommandText = "INSERT INTO MY_TABLE (NCLOB_COLUMN) VALUES (:PARAMETER1)";
    // Add string-parameters with different lengths
    // oraCommand.Parameters.Add("PARAMETER1", new string(' ', 1900)); // ok
    oraCommand.Parameters.Add("PARAMETER1", new string(' ', 2500));  // Exception
    //oraCommand.Parameters.Add("PARAMETER1", new string(' ', 4100)); // ok
    oraCommand.ExecuteNonQuery();
    
    • any string with a length under 2000 characters will not throw this exception
    • any string with a length of more than 4000 characters will not throw this exception
    • only strings with a length between 2000 and 4000 characters will throw this exception

    We opened a ticket at microsoft for this bug many years ago, but it has still not been fixed.

提交回复
热议问题