Virtual method GetFieldClass (TSmartQuery / TMemDataSet) not fired

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
tswedrowski
Posts: 9
Joined: Mon 16 Mar 2015 12:58

Virtual method GetFieldClass (TSmartQuery / TMemDataSet) not fired

Post by tswedrowski » Fri 08 May 2015 13:09

Hello.
After migration code from older ODAC (6.70.0.45 on Delphi 2009) to newer one (9.4.14 on Delphi XE7) I have a problem with virtual method GetFieldClass in TSmartQuery class (defined in TMemDataSet descendant).
In short, it is not fired on newer version.

I have a descendant of TSmartQuery with overridden GetFieldClass function:

Code: Select all

function GetFieldClass(FieldType: TFieldType): TFieldClass; override;
In Delphi 2009|Odac6.70 this function is fired for each field after executing query.
In Delphi XE7|Odac 9.4 it is not.

I have a problem to find any documentation about this function - it is mentioned only once (in 2006) on forum.

Question:
1. Why GetFieldClass is not fired?
2. Where should I look for a documentation about this function?

Best regards,
Tomasz

p.s.
in first version of this post I have misspelled function name:
wrong: GetClassField
correct: GetFieldClass

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

Re: Virtual method GetFieldClass (TSmartQuery / TMemDataSet) not fired

Post by AlexP » Tue 12 May 2015 07:30

Hello,

We can't reproduce the described problem on the latest ODAC version 9.5.15. The function is fired for each field. Please try to reproduce this behavior on the latest version and let us know the results.

tswedrowski
Posts: 9
Joined: Mon 16 Mar 2015 12:58

Re: Virtual method GetFieldClass (TSmartQuery / TMemDataSet) not fired

Post by tswedrowski » Tue 12 May 2015 09:17

Hello,
I tried it on newest ODAC 9.5.15 and GetFieldClass was not fired.
Maybe I am doing something wrong...

I made a simple example which works on old ODAC and works not on newest one:
my class:

Code: Select all

type
  TMyDataSet = class (TSmartQuery)
  protected
    function GetFieldClass(FieldType: TFieldType): TFieldClass; override;
  end;
Fake implementation:

Code: Select all

function TMyDataSet.GetFieldClass(FieldType: TFieldType): TFieldClass;
begin
  Result := TFloatField;
end;
Call:

Code: Select all

var
  v: TMyDataSet;
  s: TOraSession;
begin
  s:=TOraSession.Create(nil);
  //set s.UserName, s.Password, s.Server
  v:=TMyDataSet.Create(nil);
  v.Session := s;
  v.SQL.Text:='select 1 from dual';
  v.Execute; //<-- here GetFieldClass should be fired
  FreeAndNil(s);
  FreeAndNil(v);
end;
I've place breakpoint on GetFieldClass code

Code: Select all

  Result := TFloatField;
and it was not catched. On old ODAC and Delphi 2009 it was.

Best regards,
Tomasz

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

Re: Virtual method GetFieldClass (TSmartQuery / TMemDataSet) not fired

Post by AlexP » Tue 12 May 2015 10:30

Now, in higher Delphi versions (since Delphi 2009), you should edit your code in the following way:

Code: Select all

  TMyDataSet = class (TSmartQuery)
  protected
    function GetFieldClass(FieldDef: TFieldDef): TFieldClass; override;
  end;

tswedrowski
Posts: 9
Joined: Mon 16 Mar 2015 12:58

Re: Virtual method GetFieldClass (TSmartQuery / TMemDataSet) not fired

Post by tswedrowski » Tue 12 May 2015 11:19

Thank you.
It solves the problem.

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

Re: Virtual method GetFieldClass (TSmartQuery / TMemDataSet) not fired

Post by AlexP » Tue 12 May 2015 11:49

Glad to see that the issue was resolved. If you have any further questions, feel free to contact us.

Post Reply