Page 1 of 1

Mirgation ODAC 5.7 to ODAC 6.00

Posted: Tue 15 May 2007 06:21
by nschmied
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

Posted: Tue 15 May 2007 08:51
by Plash
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.

Posted: Tue 15 May 2007 09:04
by nschmied
Ok I wll try.
But I need to create both, Field and FieldDesc, or field enough ?

Posted: Tue 15 May 2007 09:29
by Plash
You need to create only fields.

Posted: Tue 15 May 2007 10:12
by nschmied
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.

Posted: Tue 15 May 2007 11:31
by nschmied
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 ?

Posted: Tue 15 May 2007 12:18
by Plash
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;

Posted: Tue 15 May 2007 12:27
by Plash
You need to add the following field to your class derived from TOraQuery:

Code: Select all

  FCreatingFields: boolean;

Posted: Tue 15 May 2007 13:11
by nschmied
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