Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Cath exceptions on ApplyUpdates method (FireDAC + Firebird)


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 4 - Last Post: May 12, 2017 8:52 AM Last Post By: Pablo Anizio
Atonal Franca

Posts: 2
Registered: 2/5/12
Cath exceptions on ApplyUpdates method (FireDAC + Firebird)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 30, 2017 5:05 AM
I'm facing difficulty to find a way to get errors on ApplyUpdates method, using FireDAC in memory (*CachedUpdates*). My scenario is a master-detail relationship with two TFDQuery and one TFDSchemaAdapter.
I have a check constraint on my detail table, but when it is violated, no exception is shown in runtime.
I'd like to catch the exception and rollback my transaction, in order to not apply none of the tables.
I have already tried using TFDSchemaAdapter.Reconcile and OnEeconcileError and OnReconcileRow events, but with no success so far. The exception is thrown just when I am debugging.

Could you please point me to some direction? The samples haven't helped me too much.
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: Cath exceptions on ApplyUpdates method (FireDAC + Firebird)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 1, 2017 9:45 PM   in response to: Atonal Franca in response to: Atonal Franca
Use ApplyUpdates(0).

--
With best regards,
Dmitry
Atonal Franca

Posts: 2
Registered: 2/5/12
Re: Cath exceptions on ApplyUpdates method (FireDAC + Firebird)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 3, 2017 7:00 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Dmitry Arefiev wrote:
Use ApplyUpdates(0).

--
With best regards,
Dmitry

I think I was not clear enough.
If I use TClientDataSet, just using OnReconcileError event is enough to catch errors on ApplyUpdates(0). However, with FireDAC the exceptions are raised only in debug mode.
Pablo Anizio

Posts: 10
Registered: 6/10/08
Re: Cath exceptions on ApplyUpdates method (FireDAC + Firebird)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 5, 2017 5:39 PM   in response to: Atonal Franca in response to: Atonal Franca
Atonal Franca wrote:
I'm facing difficulty to find a way to get errors on ApplyUpdates method, using FireDAC in memory (*CachedUpdates*). My scenario is a master-detail relationship with two TFDQuery and one TFDSchemaAdapter.
I have a check constraint on my detail table, but when it is violated, no exception is shown in runtime.
I'd like to catch the exception and rollback my transaction, in order to not apply none of the tables.
I have already tried using TFDSchemaAdapter.Reconcile and OnEeconcileError and OnReconcileRow events, but with no success so far. The exception is thrown just when I am debugging.

Could you please point me to some direction? The samples haven't helped me too much.

Try use this scenario:

on post button:

if SchemaAdapter.UpdatesPending then
begin
try
FDQueryMaster.Connection.StartTransaction;
if SchemaAdapter.ApplyUpdates > 0 then
Abort;
SchemaAdapter.CommitUpdates;
FDQueryMaster.Connection.Commit;
except
FDQueryMaster.Connection.Rollback;
end;
end;

on SchemaAdapterReconcileRow:

ShowMessage(ARow.RowError.Message);
Pablo Anizio

Posts: 10
Registered: 6/10/08
Re: Cath exceptions on ApplyUpdates method (FireDAC + Firebird)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 12, 2017 8:52 AM   in response to: Pablo Anizio in response to: Pablo Anizio
Pablo Anizio wrote:
Atonal Franca wrote:
I'm facing difficulty to find a way to get errors on ApplyUpdates method, using FireDAC in memory (*CachedUpdates*). My scenario is a master-detail relationship with two TFDQuery and one TFDSchemaAdapter.
I have a check constraint on my detail table, but when it is violated, no exception is shown in runtime.
I'd like to catch the exception and rollback my transaction, in order to not apply none of the tables.
I have already tried using TFDSchemaAdapter.Reconcile and OnEeconcileError and OnReconcileRow events, but with no success so far. The exception is thrown just when I am debugging.

Could you please point me to some direction? The samples haven't helped me too much.

Try use this scenario:

on post button:

if SchemaAdapter.UpdatesPending then
begin
try
FDQueryMaster.Connection.StartTransaction;
if SchemaAdapter.ApplyUpdates > 0 then
Abort;
SchemaAdapter.CommitUpdates;
FDQueryMaster.Connection.Commit;
except
FDQueryMaster.Connection.Rollback;
end;
end;

on SchemaAdapterReconcileRow:

ShowMessage(ARow.RowError.Message);

A little update:

on post button:

if SchemaAdapter.UpdatesPending then
begin
try
FDQueryMaster.Connection.StartTransaction;
if SchemaAdapter.ApplyUpdates > 0 then
Abort;
SchemaAdapter.CommitUpdates;
FDQueryMaster.Connection.Commit;
except
on E: exception do
begin
FDQueryMaster.Connection.Rollback;
raise;
end;
end;
end;

on SchemaAdapterReconcileRow:

ShowMessage(ARow.RowError.Message);
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02