ODAC 9.3.10 Object CHAR and Unicode Environment

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

ODAC 9.3.10 Object CHAR and Unicode Environment

Post by MarkF » Sat 02 Aug 2014 20:52

It appears that when UnicodeEnvironment := True that retrieving object fields that are CHAR types get read without a trailing null and show up with extra uninitialized data. Here's an example of an SQL script and a console app to show the issue.

Code: Select all

CREATE TYPE address_type AS OBJECT (
   street  VARCHAR2(30),
   city    VARCHAR2(20),
   state   CHAR(2),
   zip     CHAR(5) );
/

-- drop table customers;
CREATE TABLE customers (
   custid  NUMBER(38),
   address address_type);

INSERT INTO customers VALUES (1, address_type('101 First', 'Redwood Shores', 'CA', '94065'));
INSERT INTO customers VALUES (2, address_type('3 Beacon St.', 'Boston', 'MA', '02011'));
COMMIT;
Delphi Code (XE5)

Code: Select all

program ODACTest;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils,
  OraCall,
  Ora,
  OraObjects;

var
  FOraSession: TOraSession;
  FOraQuery: TOraQuery;
  FOraObject: TOraObject;
  S: String;
begin
  OraCall.OracleHomes.Default := OraCall.OracleHomes.AddHome('CustomHome', 'd:\oracle12_32');
  FOraSession := TOraSession.Create(nil);
  try
    FOraSession.ConnectPrompt := False;
    FOraSession.Options.UnicodeEnvironment := True;
    FOraSession.Options.UseUnicode := True;
    FOraSession.ConnectString := 'user/pw@//myserver/sid';
    FOraQuery := TOraQuery.Create(nil);
    try
      FOraSession.Connect;
      FOraQuery.ObjectView := True;
      FOraQuery.SQL.Text := 'select * from customers';
      try
        FOraQuery.Open;
        while not FOraQuery.Eof do
        begin
          Write(FOraQuery.Fields[0].AsString);
          FOraObject := FOraQuery.GetObject(FOraQuery.Fields[1].FieldName);
          S := FOraObject.AttrAsString['STATE'];
          WriteLn(':  State: "' + S + '"');
          FOraQuery.Next;
        end;
      except
        on E: Exception do
          Writeln(E.ClassName, ': ', E.Message);
      end;

    finally
      FOraQuery.Free;
    end;
    WriteLn('Press Enter to Close.');
    ReadLn;
  finally
    FOraSession.Free;
  end;
end.
On my system the output is:
1: State: "CA??????????????????????r??????"
2: State: "MA?????????????R?????????????????"

Note that varchar2 properties seem to work fine.

Thanks for any help.

-Mark Ford
Benthic Software

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: ODAC 9.3.10 Object CHAR and Unicode Environment

Post by AlexP » Mon 04 Aug 2014 09:13

Hello,

Thank you for the information. We have reproduced the problem and will investigate the reasons for such behavior.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: ODAC 9.3.10 Object CHAR and Unicode Environment

Post by AlexP » Fri 05 Sep 2014 09:41

We have fixed this behavior, the fix will be included to the next version of ODAC.

Post Reply