Question

I am using Simple.Data.Oracle to insert data in a table. I am trying to insert a very large value in one of the columns and it is giving me the following error

ORA-22835:Buffer er for lille til konvertering af CLOB til CHAR eller BLOB til RAW (faktisk: 19471, maksimum: 4000)

I am a long way ahead in the project and can't afford to dump Simple.Data.Oracle and look for other alternates at the moment...

Was it helpful?

Solution

You're converting a CLOB to a string of some description. There's a maximum of 4,000 characters in a string in SQL so you need to take a sub-string of the CLOB if you want to place it into a character.

The simplest way to do this is to use DBMS_LOB.SUBSTR.

It doesn't appear as though simple.data.oracle supports CLOBs natively; if you look at the code for the DBTypeConverter class the dictionary maps a CLOB to DBType.String:

{"CLOB", DbType.String},

This is despite the documentation linked in the comments indicating that it should be mapped to DBType.Object. Though the mappings have changed very slightly in the 11.2 documentation a CLOB is still an object.

I don't know the reasons for deciding that a CLOB is a string but as I see it you have a few options:

  1. Raise a bug report on GitHub and be prepared to be told it's not a bug.
  2. Pull a version and change it yourself - be warned that as a CLOB is assumed to be a string there may be a lot of changes to make.
  3. Use DBMS_LOB.SUBSTR and "chunk" the CLOB into as many strings as are required using the offset parameter.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top