Exception in getting date attribute from oracle object type
Posted: 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)
Delphi (XE2)
[/quote]
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;
/
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.