Page 1 of 1

Simulating ApplyUpdate

Posted: Mon 14 Jan 2013 12:17
by piopio1
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

Re: Simulating ApplyUpdate

Posted: Mon 14 Jan 2013 16:21
by AlexP
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.

Re: Simulating ApplyUpdate

Posted: Mon 14 Jan 2013 22:48
by piopio1
Thank you very much. It works of course


Pio Pio