views:

206

answers:

2

Hi, I want to insert CLOB value into my Oracle database and here is the what I could do. I got this exception while inserting operation "ORA-01461: can bind a LONG value only for insert into a LONG column". Would someone able to tell me what should I do? Thanks.

List<Object> listObjects = dao.selectAll("TABLE NAME", new XRowMapper());
String queryX = "INSERT INTO X (A,B,C,D,E,F) VALUES (?,?,?,?,?,XMLTYPE(?))";
OracleLobHandler lobHandler = new OracleLobHandler();
for(Object myObject : listObjects) {
   dao.create(queryX, new Object[]{
     ((X)myObject).getA(),
     ((X)myObject).getB(),
     new SqlLobValue (((X)myObject).getC(), lobHandler),
     ((X)myObject).getD(),
     ((X)myObject).getE(),
     ((X)myObject).getF()
     },
     new int[] {Types.VARCHAR,Types.VARCHAR,Types.CLOB,Types.VARCHAR,Types.VARCHAR,Types.VARCHAR});
}
A: 

Are your parameters in the correct order? It's like the SQL statement has the LOB as the 6th parameter, but you're setting the LOB as the 3rd parameter.

Also, I assume getA() to getF() all return String values?

skaffman
yes all getters return `String` values and in my database `column C` has a `CLOB` data type and `colum F` has an `XMLTYPE`. Therefore, I guess parameters are in the correct order.
haluk
A: 

The first thing I'd do is eliminate either column C or F from your insert to determine which one is causing the error.

DCookie