Page 1 of 1

Exception in getting date attribute from oracle object type

Posted: Wed 14 Sep 2011 11:32
by AV
I've got the exception in ODAC 7.20.0.8 while trying to access the attribute of 'date' type from an oracle object type (date attributes offsets seems to be incorrectly calculated on some objects, f.e in the following example 'DT1' attribute offset should be 2 bytes higher).

example:

ORACLE (11gR2)

Code: Select all

create or replace type scott.OT1 as object 
(
  V1 VARCHAR2(10),
  N1 NUMBER
) not final
/

create or replace type scott.OT2 under scott.OT1
(	
  DT1 DATE,
  constructor function OT2(ADate DATE) return self as result
)
/
create or replace type body scott.OT2 is

  constructor function OT2(ADate DATE) return self as result is
  begin
    SELF.DT1 := ADate;
    return;
  end;
end;
/
Delphi (XE2)

Code: Select all

program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils,
  OraObjects,
  Ora;

var
  LOraType: TOraType;
  LOraObj: TOraObject;
  LOraQuery: TOraQuery;
  LOraSession: TOraSession;
  LDate: TDateTime;
begin
  try
    LOraQuery := TOraQuery.Create(nil);
    LOraSession := TOraSession.Create(nil);
    LOraSession.ConnectString := 'user/password@server';

    LOraSession.Connect;

    try
      LOraType := TOraType.Create(LOraSession.OCISvcCtx, 'scott.OT2');
      LOraObj := TOraObject.Create(LOraType);

      LOraQuery.SQL.Clear;
      LOraQuery.SQL.Add('begin');
      LOraQuery.SQL.Add(':T := scott.OT2(sysdate);');
      LOraQuery.SQL.Add('end;');
      LOraQuery.Params.ParamByName('T').AsObject := LOraObj;
      LOraQuery.Execute;

      LDate := LOraObj.AttrAsDateTime['DT1'];
      //here i got the EConvertError with message 'Invalid argument to date encode'.

      writeln(DateToStr(LDate));
    finally
      LOraType.Free;
      LOraQuery.Free;
      LOraSession.Free;
    end;
  except
    on E: Exception do
    begin
      WriteLN(E.Message);
      Readln;
    end;
  end;
end.
[/quote]

Posted: Wed 14 Sep 2011 13:00
by AlexP
Hello,

Thank you for the information.
We have reproduced the problem.
We will notify you as soon as we have any results.

Posted: Thu 22 Sep 2011 08:49
by AV
Hello, AlexP

As you mentioned in neighboring topic, the next version 'll be released in approx two months, so is there any chance to get the fix or workaround earlier for registered users? The bug is very critical for me, and i'm just about to buy a license

Posted: Thu 22 Sep 2011 09:29
by AlexP
Hello,

We've already fixed this problem. Maybe we will release an interim version with bug fixes in the nearest future (during this month).