Writing to a CLOB in Unicode mode in Oracle 10

Writing to a CLOB in Unicode mode in Oracle 10

Postby irfan » 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
irfan
 
Posts: 15
Joined: Wed 13 Apr 2005 00:56

Postby Alexey » Fri 08 Dec 2006 12:30

What is your database encoding?
What is your OS regional settings?
Is there "Unicode=true" clause in your ConnectionString?
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby irfan » Fri 08 Dec 2006 18:04

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.
irfan
 
Posts: 15
Joined: Wed 13 Apr 2005 00:56

Postby Alexey » Mon 11 Dec 2006 07:08

What is your operation system regional settings?
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby irfan » Mon 11 Dec 2006 08:38

Regional Settings are

English (United States)

Just a basic default U.S. installation of Windows.
irfan
 
Posts: 15
Joined: Wed 13 Apr 2005 00:56

Postby Alexey » Mon 11 Dec 2006 10:49

We are investigating this problem.
You will be notified on results as soon as possible.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby Alexey » Mon 18 Dec 2006 08:06

This problem is fixed in OraDirect 3.55.15.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Problem still exists...

Postby sumit » Wed 03 Jan 2007 22:32

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!
sumit
 
Posts: 62
Joined: Wed 03 Jan 2007 22:23

Postby sumit » Tue 09 Jan 2007 01:59

Hi Alexey,

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

Thanks.
sumit
 
Posts: 62
Joined: Wed 03 Jan 2007 22:23

Postby Alexey » Wed 10 Jan 2007 08:15

This problem is fixed.
Look forward to the next build.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43


Return to dotConnect for Oracle