Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: ORA 1461 Error while trying to insert into a CLOB column
In article <Pine.OSF.4.05.9811301408560.4188-100000_at_curly.cc.utexas.edu>,
Ajay Damani <damani_at_uts.cc.utexas.edu> wrote:
>
> Hi folks!
>
> I am getting the following error while trying to insert something into an
> Oracle8 database:
>
> "java.sql.SQLException: ORA-01461: can bind a LONG value only for insert
> into a LONG column"
>
> I am using v8.0.5.0.5 of the JDBC drivers obtained from Oracle together
> with JDK 1.1.6. My column type is a CLOB and this only happens
> while trying to insert something over a certain size (i believe that the
> size limit is 4k). My question is as follows:
>
> 1. Is there a better way to insert something into a CLOB column of an
> Oracle8 database without encountering the above error message and
> overcoming the size limit? Currently I am using the following
> code:
>
> // this can be something as big as you can imagine.
> String mydata = "something really really long.........";
> int len = mydata.length();
>
> BytaArrayInputStream bais = new ByteArrayInputStream(mydata.toBytes());
> PreparedStatement ps = conn.prepeareStatement("insert into mytable
> values (?)");
> ps.setAsciiStream(1,bais,len);
> // Also tried the following:
> // ps.setString(1,outputstream.toString());
> ps.execute();
> ps.close();
>
> This does the insert for data of a certain size but croaks on anything
> that is over the size limit.
>
> 2. If I can somehow convert my string (mydata) to an OracleClob, then I
> can use the setClob method to do the insert. Can I do this?
>
> Any help is greatly appreciated. Thanks.
>
> -Ajay
>
>
When you insert CLOB, you insert a LOCATOR, or reference, not the actual
data. To insert actual data, you should call LOB Read/Write functions.
I don't know much about Java, but in OCI, when you define query output,
the type for LOB columns is OCILobLocator *lobptr. That lobptr is then
handed to OCILobRead and OCILobWrite (together with service context and
error handle pointers as well as some other arguments). I'm sure that Oracle
JDBC driver has methods for invoking those functions.
Regards,
Mladen Gogala
-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Wed Dec 02 1998 - 13:54:57 CST
![]() |
![]() |