Oracle一个诡异的错误——Can bind a LONG value only for insert into a LONG column

Oracle一个诡异的错误——Can bind a LONG value only for insert into a LONG column

CrmProductTaskEndAction : SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [72000]; error code [1461];   
--- The error occurred in com/alibaba/intl/bops/crm/syslog/dao/ibatis/sqlmap/CRM_SYSLOG_EMAIL.xml.  
--- The error occurred while applying a parameter map.  
--- Check the CRM_SYSLOG_EMAIL.insert-InlineParameterMap.  
--- Check the statement (update failed).  
Error: java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column

   at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
   at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
   at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
   at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
   at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
   at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:955)
   at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1168)
   at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3316)
   at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3422)
   at com.alibaba.ark.jdbc.PreparedStatementWrapper.execute(PreparedStatementWrapper.java:136)

原因就是字段超长。LONG column是Oracle老的BLOB数据类型,已经deplicated了,Use BLOB instead of LONG。

Datatype Description Max Size:Oracle 8 Max Size:Oracle 9i/10g Max Size:Oracle 11g Max Size:PL/SQL PL/SQL Subtypes/Synonyms
VARCHAR2(size) Variable length character string having maximum length size bytes. You must specify size 4000 bytes minimum is 1 4000 bytes minimum is 1 4000 bytes minimum is 1 32767 bytes minimum is 1 STRING VARCHAR
LONG Character data of variable length (A bigger version the VARCHAR2 datatype) 2 Gigabytes 2 Gigabytes - but now deprecated (provided for backward compatibility only). 2 Gigabytes - but now deprecated (provided for backward compatibility only). 32760 bytes Note this is smalller than the maximum width of a LONG column  

但是将同样的SQL放在pldev终端直接跑,确实报另外一个错误:

ORA-01401:insert value too large for column

具体参考:Oracle/PLSQL: ORA-01401 Error

为什么同样的SQL,会跑出不同的错误结果,仔细看异常堆栈,发现前面的ORA-01461错误是Oracle JDBC驱动(ojdbc14)抛出来的。


你可能感兴趣的:(java,oracle,sql,ibatis,jdbc)