Using the TOraQuery-TProvider-TClientDataSet model

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
lior
Posts: 36
Joined: Mon 01 Aug 2011 07:11

Using the TOraQuery-TProvider-TClientDataSet model

Post by lior » Sun 28 Aug 2011 12:54

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;

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Tue 30 Aug 2011 10:18

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.

lior
Posts: 36
Joined: Mon 01 Aug 2011 07:11

Post by lior » Tue 30 Aug 2011 12:07

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;

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Thu 01 Sep 2011 14:06

Hello,

I have answered you by e-mail.

Post Reply