Mirgation ODAC 5.7 to ODAC 6.00

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
nschmied
Posts: 72
Joined: Mon 09 May 2005 08:03
Location: Suisse

Mirgation ODAC 5.7 to ODAC 6.00

Post by nschmied » Tue 15 May 2007 06:21

Hi,

First thank you for your work on VCL.NET.

I have buy your last version about ODAC 6.00, and I migrate to this new version.

But I have a trouble with calculated Fields.

With previous ODAC 5.7 I create manually calculate filed with override procedure CreateFields.

The manually creation it's like this

Code: Select all

            fldBase := TStringField.Create(DataSet);
          With fldBase do
          begin
            FieldName   := Self.CalcFieldName;
            DataSet     := Self.DataSet;
            Calculated  := True;
            Visible     := True;
            ReadOnly    := True;
            Size        := Self.Size;
            DisplayWidth:= Self.Size;
          end;
And work fine with ODAC 5.7

But now with new version it's not work fine. The creation it's OK, but after when I want to use my field I receive a error Message : "Field not found".

Can you explain me how-to use calculated field now ?

Thanks for you help,
Regards,
N.Schmied

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Tue 15 May 2007 08:51

In ODAC 6 we added ability to use calculated fields for sorting and filtering. But now all fields must be created before a dataset will be open. For example, you can override the OpenCursor method of TDataSet, and create calculated fields before calling the inherited method.

nschmied
Posts: 72
Joined: Mon 09 May 2005 08:03
Location: Suisse

Post by nschmied » Tue 15 May 2007 09:04

Ok I wll try.
But I need to create both, Field and FieldDesc, or field enough ?

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Tue 15 May 2007 09:29

You need to create only fields.

nschmied
Posts: 72
Joined: Mon 09 May 2005 08:03
Location: Suisse

Post by nschmied » Tue 15 May 2007 10:12

I have try that you say.
But it's not work. Now the Fields list containt only my two calculated fields.

But FieldsDesc from Data Object containt all.

I don't know wath's append but it's not work well.

nschmied
Posts: 72
Joined: Mon 09 May 2005 08:03
Location: Suisse

Post by nschmied » Tue 15 May 2007 11:31

I have found it. I don't need to create defore OpenCursor, but before InternalOpen.

But, always but, now the memory was not clear. Have have many error "memory not be ready" and after process break down.

next ?

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Tue 15 May 2007 12:18

Try to use the following code:

Code: Select all

procedure TMyOraQuery.OpenCursor(InfoQuery: boolean);
var
  fldBase: TField;
begin
  if not FCreatingFields then begin
    FCreatingFields := True;

    FieldDefs.Update;
    CreateFields;

    fldBase := TStringField.Create(Self);
    with fldBase do
    begin
      FieldName   := 'a';
      DataSet     := Self;
      Calculated  := True;
      Visible     := True;
      ReadOnly    := True;
      Size        := 10;
      DisplayWidth:= Size;
    end;

    FCreatingFields := False;
  end;

  inherited;
end;

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Tue 15 May 2007 12:27

You need to add the following field to your class derived from TOraQuery:

Code: Select all

  FCreatingFields: boolean;

nschmied
Posts: 72
Joined: Mon 09 May 2005 08:03
Location: Suisse

Post by nschmied » Tue 15 May 2007 13:11

Plash wrote:You need to add the following field to your class derived from TOraQuery:

Code: Select all

  FCreatingFields: boolean;
Yes have have see.


And I have need to added

Code: Select all

      if Fields.Count > 0 then
        DestroyFields;
Before CreateFields;
because if a call next time my dataset close; Open; there are duplicate fields.

I think it's work now.
Thanks for your help

Post Reply