Page 1 of 1

Virtual method GetFieldClass (TSmartQuery / TMemDataSet) not fired

Posted: Fri 08 May 2015 13:09
by tswedrowski
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

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

Posted: Tue 12 May 2015 07:30
by AlexP
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.

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

Posted: Tue 12 May 2015 09:17
by tswedrowski
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

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

Posted: Tue 12 May 2015 10:30
by AlexP
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;

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

Posted: Tue 12 May 2015 11:19
by tswedrowski
Thank you.
It solves the problem.

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

Posted: Tue 12 May 2015 11:49
by AlexP
Glad to see that the issue was resolved. If you have any further questions, feel free to contact us.