Subject Re: Transaction open after a required field not populated , how to fix
Author Eric Handbury
--- In IBObjects@y..., "wayne" <waynef@w...> wrote:
> I have a From wtih many datasets...
> They are all in insert mode, all fields are populated with correct
data,
> except one REQUIRED field has no data.
>
> My Code below is not perfect since a transaction will be
Open/Started for
> an undetermine period of time.
>
>
> ************OnClick Event Code Below ******************
> try
> tableAcc.Post;
> tableEnq.Post;
> rbUpdate1.FlushCache;
> except on e: Exception do
> begin
> MessageDlg('Error ', mtWarning, [mbOK], 0);
> exit; // Get out of here and dont Commit yet //
> *****************we have a TRansaction Open *****************
> *** Start a Timer ***
> end;
>
> try
> trClient.Commit;
> Close; // Close the Form
> except on e: Exception do
> begin
> MessageDlg('Error Rolling back' , mtWarning, [mbOK], 0);
> trClient.Rollback;
> end;
> end;

Why can't you Rollback on the 1st exception? Or do a
RollbackRetaining so that the datasets remain open, but the
Transaction is killed.