Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 someone please help me on the cause and solution of the problem?

like image 674
Rupesh Avatar asked Feb 06 '12 05:02

Rupesh


People also ask

Can bind a LONG value only for insert into a long column VARCHAR2?

In SQL the max length of a VARCHAR2 is 4000 bytes; not characters but bytes. Anything longer than 4000 bytes would probably be considered a LONG in the generic sense. means you are trying to 'bind a LONG value' to a VARCHAR2 column and you cannot you can 'bind a LONG value only for insert into a LONG column'.

How do I fix my ORA 01461?

Answer: The LONG and LONG RAW datatypes have been deprecated and the easiest solution to the ORA-01461 error is to change the column datatype to as CLOB. The replier suggested that instead of using LONG as the column, that ORA-01461 could be avoided if the binary stream was LONG RAW instead.

What is long datatype in Oracle?

The LONG datatype can store variable-length character data containing up to two gigabytes of information. The length of LONG values might be limited by the memory available on your computer. You can use columns defined as LONG in SELECT lists, SET clauses of UPDATE statements, and VALUES clauses of INSERT statements.


1 Answers

It can also happen with varchar2 columns. This is pretty reproducible with PreparedStatements through JDBC by simply

  1. creating a table with a column of varchar2 (20 or any arbitrary length) and
  2. inserting into the above table with a row containing more than 20 characters

So as above said it can be wrong with types, or column width exceeded.

Also note that as varchar2 allows 4k chars max, the real limit will be 2k for double byte chars

Hope this helps

like image 163
Kiran Avatar answered Oct 19 '22 11:10

Kiran