Page 1 of 1

Writing to a CLOB in Unicode mode in Oracle 10

Posted: Fri 08 Dec 2006 10:05
by irfan
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

Posted: Fri 08 Dec 2006 12:30
by Alexey
What is your database encoding?
What is your OS regional settings?
Is there "Unicode=true" clause in your ConnectionString?

Posted: Fri 08 Dec 2006 18:04
by irfan
Issuing the following SQL returns the character sets below.

select * from nls_database_parameters where parameter like '%CHARACTERSET'

NLS_CHARACTERSET AL32UTF8
NLS_NCHAR_CHARACTERSET AL16UTF16

Yes I have Unicode=true in my connection string.

I have also tried using UTF8Encoding class in the examples above that I have provided without any luck.

Posted: Mon 11 Dec 2006 07:08
by Alexey
What is your operation system regional settings?

Posted: Mon 11 Dec 2006 08:38
by irfan
Regional Settings are

English (United States)

Just a basic default U.S. installation of Windows.

Posted: Mon 11 Dec 2006 10:49
by Alexey
We are investigating this problem.
You will be notified on results as soon as possible.

Posted: Mon 18 Dec 2006 08:06
by Alexey
This problem is fixed in OraDirect 3.55.15.

Problem still exists...

Posted: Wed 03 Jan 2007 22:32
by sumit
Hi Alexey,

Irfan is not available for few weeks so I am following up on the issue.

The problem still exists with the latest version of the drivers. If however, I change
myLob = new OracleLob(this._connection as OracleConnection, OracleDbType.Blob);

to

myLob = new OracleLob(this._connection as OracleConnection, OracleDbType.Clob);

, I do not get garbage data but instead the data gets truncated in Oracle 10g Unicode = True and in Oracle 9i Unicode = True, I get ORA-06505 error.

If I do not make this change,
Oracle 9i (Unicode) works and Oracle 10g (Unicode) gives me junk characters even in the latest drivers.

I have a sample project that connects to 10g (Unicode) where the string gets truncated. Please let me know how to send you the sample project.

Any help will be appreciated. Thanks!

Posted: Tue 09 Jan 2007 01:59
by sumit
Hi Alexey,

Is there any update on the issue? We are very close to our release date and thats making everyone here nervous.

Thanks.

Posted: Wed 10 Jan 2007 08:15
by Alexey
This problem is fixed.
Look forward to the next build.