Link to home
Start Free TrialLog in
Avatar of ChiBella
ChiBella

asked on

Oracle 9i Insert into Clob > 4000 Bytes

Need to insert more than 4000 of data into an Oracle Clob column. I notice the size on the clob column is 4000 by default. I'm using Oracle 9i.

We are using .net/c#. How do we insert more than 4k bytes in a clob field (Oracle 9i)?
Avatar of JimBrandley
JimBrandley
Flag of United States of America image

When you set the parameter for your insert:
OracleParameter OracleParam = new OracleParameter();
OracleParam.OracleDbType=OracleDbType.Clob;
OracleParam.Value = yourNewValue;
OracleParam.ParameterName = name;
// DO NOT set the size!      OracleParam.Size = length;
OracleParam.Direction = ParameterDirection.Input;

This has worked for me in both 9i and 10g.

Jim
Avatar of ChiBella
ChiBella

ASKER

Are you sending parameter to a stored procedure? How do we do this without a stored procedure..using an insert sql or update sql?
I use bind parameters for all DB invocations. Build your insert statement like this:
"INSERT INTO mytable VALUES( :1, :2)"

Then add two bind parameters, one for the key and one for the clob to the parameter collection of the OracleCommand object.

Bind parameters make your code run faster because it can avoid hard parses on the DB server.
I see ...

So the insert value can be greater than 4000 bytes?

How about an update > 4000 bytes?
Same thing. CLOB size is a huge number (don't remember the exact limit, but 3 GB rings a bell).
Everywhere I look states there is a limit to the amount you can pass directly (4k) and you have to do it in chunks. We will try your method and let you know.

thanks
ASKER CERTIFIED SOLUTION
Avatar of JimBrandley
JimBrandley
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial