Writing to a CLOB in Unicode mode in Oracle 10
Posted: Fri 08 Dec 2006 10:05
I am using OraDirect .NET in Direct mode (direct=true) to talk to an Oracle 10 database that is configured for UTF-16 (Unicode). I am trying to write a 12 Kbyte string to a column in the database which has type CLOB.
If I follow the example provided of writing the CLOB and set the value of Size to the maximum that the CLOB can support
parameter.Size=100000;
parameter.Value = pXmlString;
parameter.Direction = ParameterDirection.Input;
The first couple of thousand characters are fine when I read it back, but the remaining are garbage.
If I use the following to compute the size
UnicodeEncoding encoding = new UnicodeEncoding();
byteArray = encoding.GetBytes(pXmlString);
parameter.Size = byteArray.Length;
parameter.Value = pXmlString;
parameter.Direction = ParameterDirection.Input;
I still get the same garbage.
If I do
myLob = new OracleLob(this._connection as OracleConnection, OracleDbType.Blob);
UnicodeEncoding encoding = new UnicodeEncoding();
byte[] data = encoding.GetBytes(pXmlString);
myLob.Write(data, 0, data.Length);
parameter.Value = myLob;
parameter.Direction = ParameterDirection.Input;
everything is garbage.
The last example however works with Oracle 9 in Unicode mode.
Can you tell me how would I go about saving Unicode data into the Oracle 10 database using the OraDirect.NET driver without having the be corrupted when I retrieve it.
Thank you,
Irfan
If I follow the example provided of writing the CLOB and set the value of Size to the maximum that the CLOB can support
parameter.Size=100000;
parameter.Value = pXmlString;
parameter.Direction = ParameterDirection.Input;
The first couple of thousand characters are fine when I read it back, but the remaining are garbage.
If I use the following to compute the size
UnicodeEncoding encoding = new UnicodeEncoding();
byteArray = encoding.GetBytes(pXmlString);
parameter.Size = byteArray.Length;
parameter.Value = pXmlString;
parameter.Direction = ParameterDirection.Input;
I still get the same garbage.
If I do
myLob = new OracleLob(this._connection as OracleConnection, OracleDbType.Blob);
UnicodeEncoding encoding = new UnicodeEncoding();
byte[] data = encoding.GetBytes(pXmlString);
myLob.Write(data, 0, data.Length);
parameter.Value = myLob;
parameter.Direction = ParameterDirection.Input;
everything is garbage.
The last example however works with Oracle 9 in Unicode mode.
Can you tell me how would I go about saving Unicode data into the Oracle 10 database using the OraDirect.NET driver without having the be corrupted when I retrieve it.
Thank you,
Irfan