Exception in getting date attribute from oracle object type

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
AV
Posts: 4
Joined: Wed 14 Sep 2011 11:12
Location: Russian Federation

Exception in getting date attribute from oracle object type

Post by AV » Wed 14 Sep 2011 11:32

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]

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

Post by AlexP » Wed 14 Sep 2011 13:00

Hello,

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

AV
Posts: 4
Joined: Wed 14 Sep 2011 11:12
Location: Russian Federation

Post by AV » Thu 22 Sep 2011 08:49

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

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

Post by AlexP » Thu 22 Sep 2011 09:29

Hello,

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

Post Reply