Simulating ApplyUpdate

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
piopio1
Posts: 32
Joined: Thu 10 Jan 2013 23:13

Simulating ApplyUpdate

Post by piopio1 » Mon 14 Jan 2013 12:17

Hello,


I am developing a TForm with a number of PGTables and PGQueries in it. All of them are linked to each other via master/detail.

As I want to update all these PGTables+PGQueries at the same time, they all have CachedUpdated=True and LocalMasterDetails=True.

All these tables have constrains set on PostgreSQL DB on the server. As soon as I fire PGTable.ApplyUpdate the records will be saved in the DB and if there is an exception then it will be raised in Delphi. My application will manage these exceptions.

For some reasons I want to check if the data in the records the user amends/adds/cancels is consistent with the constrain rules BEFORE firing ApplyUpdate and I was wondering if there a way to simulate an ApplyUpdate so that I can have an exception I can manage before the real ApplyUpdate is activated.

Many thanks

Pio Pio

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

Re: Simulating ApplyUpdate

Post by AlexP » Mon 14 Jan 2013 16:21

Hello,

For the purpose, you can use the transaction engine, i.e., before applying changes to the table, start the transaction PgConnection1.StartTransaction, after applying changes - invoke ApplyUpdate of DataSet. If there are problems (e.g. Constraints actuate) when executing ApplyUpdate, you will be able to handle these errors and run PgConnection1.Rollback to rollback all the changes applied on the server independently on the DataSet where errors occur. There is no another way to check server limitations.

piopio1
Posts: 32
Joined: Thu 10 Jan 2013 23:13

Re: Simulating ApplyUpdate

Post by piopio1 » Mon 14 Jan 2013 22:48

Thank you very much. It works of course


Pio Pio

Post Reply