Using the TOraQuery-TProvider-TClientDataSet model, how do I update
Back to the server edit changes when the query is a multi table join?
In my old BDE application I used the TProvider BeforeUpdateRecord event
As the Delphi 7 help shows:
procedure TRemoteDataModule1.Provider1BeforeUpdateRecord(Sender: TObject; SourceDS: TDataSet; DeltaDS: TCustomClientDataSet; UpdateKind: TUpdateKind; var Applied Boolean);
begin
UpdateSQL1.DataSet := DeltaDS; { required for the automatic parameter substitution }
with UpdateSQL1.Query[UpdateKind] do
begin
{ Make sure the query has the correct DatabaseName and SessionName }
DatabaseName := (SourceDS as TDBDataSet).DatabaseName;
SessionName := (SourceDS as TDBDataSet).SessionName;
ParamByName('TimeOfUpdate').Value = Now;
end;
UpdateSQL1.Apply(UpdateKind); { now perform automatic substitutions }
Applied := True;
end;
Using the TOraQuery-TProvider-TClientDataSet model
Hello,
Editing is done in the ClientDataSet. ClientDataSet.ApplyUpdates sends changes to the provider for writing to the database.
I think TOraQuery is only used to provide initial input for the Provider and ClientDataSet.
My question is where and how to update all the tables that where changed in the join.
In the non ODAC application it used to be in the Provider.BeforeUpdateRecord event.
This code is from the Delphi help example:
procedure TRemoteDataModule1.Provider1BeforeUpdateRecord(Sender: TObject; SourceDS: TDataSet; DeltaDS: TCustomClientDataSet; UpdateKind: TUpdateKind; var Applied Boolean);
begin
UpdateSQL1.DataSet := DeltaDS; { required for the automatic parameter substitution }
with UpdateSQL1.Query[UpdateKind] do
begin
{ Make sure the query has the correct DatabaseName and SessionName }
DatabaseName := (SourceDS as TDBDataSet).DatabaseName;
SessionName := (SourceDS as TDBDataSet).SessionName;
ParamByName('TimeOfUpdate').Value = Now;
end;
UpdateSQL1.Apply(UpdateKind); { now perform automatic substitutions }
Applied := True;
end;
Editing is done in the ClientDataSet. ClientDataSet.ApplyUpdates sends changes to the provider for writing to the database.
I think TOraQuery is only used to provide initial input for the Provider and ClientDataSet.
My question is where and how to update all the tables that where changed in the join.
In the non ODAC application it used to be in the Provider.BeforeUpdateRecord event.
This code is from the Delphi help example:
procedure TRemoteDataModule1.Provider1BeforeUpdateRecord(Sender: TObject; SourceDS: TDataSet; DeltaDS: TCustomClientDataSet; UpdateKind: TUpdateKind; var Applied Boolean);
begin
UpdateSQL1.DataSet := DeltaDS; { required for the automatic parameter substitution }
with UpdateSQL1.Query[UpdateKind] do
begin
{ Make sure the query has the correct DatabaseName and SessionName }
DatabaseName := (SourceDS as TDBDataSet).DatabaseName;
SessionName := (SourceDS as TDBDataSet).SessionName;
ParamByName('TimeOfUpdate').Value = Now;
end;
UpdateSQL1.Apply(UpdateKind); { now perform automatic substitutions }
Applied := True;
end;