Add missing TFields / can't write that Fields

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Jank
Posts: 35
Joined: Tue 11 May 2010 11:57

Add missing TFields / can't write that Fields

Post by Jank » Tue 09 Aug 2016 08:39

Hi,

I have a TIBCQuery with a few TFields at Designtime, not all of the result.
Now I set Property "FieldOptions.AutoCreateMode" (comes from TDataset) to acCombineAlways.
This didn't work, because in "TMemDataSet.InternalOpen" the method "CreateFields" is only called "if not (lcPersistent in Fields.LifeCycles)".
I removed that line and my plan works, it adds missing tfields. Is there a option that it works without removing the line "if not (lcPersistent in Fields.LifeCycles) then"?

An I have a Problem in the follow up:
I have my TField and can write data to it. then i call the post-method and it writes no data to the field in the database.
Then I make a edit and post again, it writes the data to the database. What do i wrong?

Code: Select all

 
IBCConnection1.Open;
  IBCQuery1.ParamByName('id').AsInteger := 1;
  IBCQuery1.Open;
  IBCQuery1.Edit;
  IBCQuery1.FieldByName('name').AsString := 'asdf 1 ' + IntToStr(Random(1000));
  IBCQuery1.Post; // name has not the value in the DB
  IBCQuery1.Close;

  IBCQuery1.Open;
  IBCQuery1.Edit;
  IBCQuery1.FieldByName('name').AsString := 'asdf 2 ' + IntToStr(Random(4000));
  IBCQuery1.Post; // name has the value in the DB
  IBCQuery1.Close;
  IBCConnection1.Close;
A SQL-Monitor-Log of this code with Options.Updateallfields = true. You see, name is updated only in the second Update-Statement.

Code: Select all

Connect: VARIO@localhost/3050
Start: 

-------------------------

select benutzer, name from ben
where id = :id
order by id
:id(INTEGER)=1

-------------------------

UPDATE BEN
SET
  BENUTZER = ?
WHERE
  BENUTZER = ?

:BENUTZER(CHAR[3],IN)='NEU' 
:Old_BENUTZER(CHAR[3],IN)='NEU'

-------------------------

CommitRetaining: 

-------------------------

select benutzer, name from ben
where id = :id
order by id
:id(INTEGER)=1

-------------------------

UPDATE BEN
SET
  BENUTZER = ?, NAME = ?
WHERE
  BENUTZER = ?

:BENUTZER(CHAR[3],IN)='NEU' 
:NAME(VARCHAR[11],IN)='asdf 2 1305' 
:Old_BENUTZER(CHAR[3],IN)='NEU'

-------------------------

CommitRetaining: 
Commit: 
Disconnect: VARIO@localhost/3050

IBDAC 5.7.24 - Delphi 10 Seattle


I hope that was comprehensible :).

Regards, Jan

Jank
Posts: 35
Joined: Tue 11 May 2010 11:57

Re: Add missing TFields / can't write that Fields

Post by Jank » Tue 09 Aug 2016 12:26

For the first point:
I Have a derived version of TFields and set in the constructor the OnChange-Event and in the OnChangeEvent I set LifeCycles to lcAutomatic. That theems to work (except if I prepare my query).

Code: Select all

unit MyFields;

interface

uses
  Data.DB;

type
  TMyFields = class(TFields)
  strict private
    procedure OnFieldsChanged(Sender: TObject);
  public
    constructor Create(ADataSet: TDataSet); override;
  end;

implementation


{ TMyFields }


procedure TMyFields.OnFieldsChanged(Sender: TObject);
begin
  self.LifeCycles := [lcAutomatic];
end;

{ TMyFields }

constructor TMyFields.Create(ADataSet: TDataSet);
begin
  Inherited;
  self.OnChange := OnFieldsChanged;
end;
And I have a derived version of TIBCQuery, there I set the fieldclass:

Code: Select all

function TMyIBCQuery.GetFieldsClass: TFieldsClass;
begin
  result := TMyFields;
end;
But is there a way that is a little bit more nice?

For point 2:
In TDataSetService.PreInitCursor there is a check, that sets the FieldDesc.Updateable Property for my field, that is added automatically to false, because it is in FDataSet.Data.Fields, but not in FDataSet.fields.
The change from Point one solves also this point.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Add missing TFields / can't write that Fields

Post by ViktorV » Wed 10 Aug 2016 11:58

Currently, IBDAC doesn't support the FieldOptions property.
If you want us to implement the feature, please post it at our user voice forum: https://devart.uservoice.com/forums/104 ... e-firebird If the suggestion gets a lot of votes, we will consider the possibility to implement it.

Jank
Posts: 35
Joined: Tue 11 May 2010 11:57

Re: Add missing TFields / can't write that Fields

Post by Jank » Fri 12 Aug 2016 15:17

Okay, thank you, I did it.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Add missing TFields / can't write that Fields

Post by ViktorV » Tue 16 Aug 2016 06:57

Thank you for being interested in our products.
If you have any questions concerning our products, please don't hesitate to contact us - and we will try to help you resolve them.

Post Reply