Page 1 of 1

Unicode string in CLOB

Posted: Fri 23 Jun 2006 16:25
by kutmon
Hello,

we have some problems displaying unicode strings stored in CLOB, international characters (arabian,russian,...) are displayed as ???????. Strings are read through TOraQuery and displayed in TTntDBMemo component. VARCHAR2 columns are displayed correctly, only CLOB seems to be a problem.

We use Delphi 7, ODAC 5.70.1.33, OCI 9.2.0.5.0, Server: Oracle 9.2.0.6.0
TOraSession settings:
CharLength := 0;
Charset := '';
UseUnicode := True;
Net := False;

it appears to me that TBLOBField doesn't handle unicode strings correctly, so I tried to read it with following code:

Code: Select all

function TMyBLOBField.GetAsWideString: WideString;
var
  Len: Integer;
begin
  with DataSet.CreateBlobStream(Self, bmRead) do
    try
      Len := Size;
      SetLength(Result,Len);
      ReadBuffer(Pointer(Result)^, Len);
    finally
      Free;
    end;
end;
as a result, I get string where first half is scrambled and second half is ok (international characters displayed correctly)

does anybody know how to read unicode strings from CLOB correctly?

thanx in advance

Tomas

Posted: Mon 26 Jun 2006 13:52
by Plash
To read CLOB field value you can use TOraDataSet.GetLob(const FieldName: string): TOraLob method and AsWideString property of TOraLob class. For example:

Code: Select all

TntMemo.Text := OraTable.GetLob("CLOB_FIELD").AsWideString;