3

Without Data Type is CLOB I can easy to read Oracle Table data , but unfortunately I do got a serious problem when some tables have the CLOB of data type , how can I do .

Error Message

{"$id":"1","Message":"An error has occurred.","ExceptionMessage":"The 'ObjectContent1' type failed to serialize the response body for content type 'application/json; charset=utf-8'.","ExceptionType":"System.InvalidOperationException","StackTrace":null,"InnerException":{"$id":"2","$type":"System.Web.Http.HttpError, System.Web.Http","Message":"An error has occurred.","ExceptionMessage":"Exception of type 'System.OutOfMemoryException' was thrown.","ExceptionType":"System.OutOfMemoryException","StackTrace":" at System.String.Concat(String str0, String str1)\r\n at OracleInternal.I18N.Conv.ConvertBytesToString(IList1 bytes, Int32 bytesOffset, Int32 bytesCount, Char[] chars, Boolean bUseReplacementChar)\r\n at OracleInternal.I18N.Conv.ConvertBytesToString(IList1 bytes, Char[] chars, Boolean bUseReplacementChar)\r\n at OracleInternal.ServiceObjects.OracleClobImpl.GetCompleteClobData(Int32 currentRow, Int32 columnIndex, OracleConnectionImpl connImpl, Byte[] lobLocator, DataUnmarshaller dataUnmarshaller, TTCLobAccessor lobAccessor, OracleClobImpl& oraClobImpl)\r\n at Oracle.ManagedDataAccess.Client.OracleDataReader.GetString(Int32 i)\r\n at lambda_method(Closure , Shaper )\r\n at System.Data.Entity.Core.Common.Internal.Materialization.Shaper.HandleEntityAppendOnly[TEntity](Func2 constructEntityDelegate, EntityKey entityKey, EntitySet entitySet)\r\n at lambda_method(Closure , Shaper )\r\n at System.Data.Entity.Core.Common.Internal.Materialization.Coordinator1.ReadNextElement(Shaper shaper)\r\n at System.Data.Entity.Core.Common.Internal.Materialization.Shaper1.SimpleEnumerator.MoveNext()\r\n at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)\r\n at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)\r\n at Newtonsoft.Json.JsonSerializer.Serialize(JsonWriter jsonWriter, Object value)\r\n at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n at System.Net.Http.Formatting.JsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content)\r\n at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n at System.Web.Http.WebHost.HttpControllerHandler.d__1b.MoveNext()"}}

PS: Environment
1. Visual Studio 2015
2. ASP.NET MVC WebApi (entity framework)
3. Oracle 11G
4. use VS default Web API project

2
  • hi did you miss some components , can you check nuget like Entity framework / Oracle etc. that are updated to latest version Commented Mar 22, 2016 at 3:42
  • I have updated all latest stable version in my project Commented Mar 22, 2016 at 3:43

1 Answer 1

1

"Exception of type 'System.OutOfMemoryException' was thrown."

I guess your CLOB object is too big to be transformed. How big is it? Check your available memory during the program execution. Do you have enough free memory?

Based on this answer on the Oracle Community looks like there are a couple of issues in the .net driver when CLOB is involved; a suggestion I found there is to try parse the CLOB as a generic BLOB and read it as byte[]. Than you can transform the byte[] to string like this

string result = System.Text.Encoding.UTF8.GetString(byteArray);

Sign up to request clarification or add additional context in comments.

4 Comments

thanks you , you are right , the memory was thrown .
sorry to bother again , In fact the CLOB data don't have many data , for all data capacity just 6MB but my memory has 4G with VM , do you have any idea ,thanks again
@Luca yes I have the same question , do you have any suggestions ,thank
I updated the answer with a couple of info I found the oracle community website. May worth a try.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.