Page 1 of 1

Using the TOraQuery-TProvider-TClientDataSet model

Posted: Sun 28 Aug 2011 12:54
by lior
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;

Posted: Tue 30 Aug 2011 10:18
by AlexP
Hello,

If more than one table is used into your query for correct inserting, updating or deleting of the record, you should define the table name data of which you are going to modify in the OraQuery.UpdatingTable property, and also define the SQLInsert, SQLUpdate and other properties.

Posted: Tue 30 Aug 2011 12:07
by lior
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;

Posted: Thu 01 Sep 2011 14:06
by AlexP
Hello,

I have answered you by e-mail.