Subject RE: [IBO] "Transaction has already been started"
Author Alan McDonald
ahh who's brew

> -----Original Message-----
> From: brew-support@... [mailto:brew-support@...]
> Sent: Sunday, 24 August 2003 4:39 PM
> To: IBObjects@yahoogroups.com
> Subject: RE: [IBO] "Transaction has already been started"
>
>
> Thank you for submitting your request to BREW Support. Your
> service request number is 18333916. Please use this number for
> future reference. If at any time you wish to update your case,
> please reply to this email or send us an email with "UPDATE
> 18333916" in the Subject: line. Doing so will automatically
> update our records.
>
> Thank you.
> BREW Support Team.
>
>
> [THREAD ID: 1-4YMHQ]
>
> -----Original Message-----
> From: helebor@...
> Sent: 8/23/2003 11:37:22 PM
> To: brew-support@...
> Subject: Re: [IBO] "Transaction has already been started"
>
> At 02:18 PM 24/08/2003 -0500, you wrote:
> >I've the following error "Transaction has already been started" (when an
> >exeption has been raised before) as result of this code:
> >
> >
> >DBO_DataModule.IB_Transaction1.StartTransaction;
> >FSQLCommand.InsertSQL.Text := sSQL;
> >
> > try
> >
> > FSQLCommand.ExecSQL(ukInsert);
> > DBO_DataModule.IB_Transaction1.Commit;
> >
> > except
> >
> > {this line do not closes transaction}
> > DBO_DataModule.IB_Transaction1.CancelAll;
>
> Correct. It does not "close" or cancel or end the transaction.
> It cancels
> any unposted work in the datasets that are associated with the
> transaction.
>
>
> > {this line closes all queries too}
> > DBO_DataModule.IB_Transaction1.Close;
>
> Correct. That is what the Close method of the transaction is for.
>
> > end;
> >
> >
> >How to close a TIB_Transaction component without have the same
> effect on the
> >Queries asociated with it?
>
> The Close method of a transaction tries to commit any outstanding
> work; if
> this fails, then it cancels the work (all of it), rolls back the
> transaction and closes the datasets. Don't call IB_Transaction.Close
> unless that is what you want to happen. It is usually called as part of
> the destruction sequence when the form or application shuts down.
>
> If a transaction cannot commit for some reason, then the most usual way to
> deal with it will be to roll it back and then proceed to fix whatever it
> was that caused the failure. That means you need to trap the
> exception and
> get the user back to a position where the work can be corrected and
> presented in a fresh transaction.
>
> Going back to the subject of this email, you get the "Transaction has
> already been started" if you try to start a transaction in a transaction
> object that already has a started transaction. Whenever you call
> StartTransaction, you need to test to ensure that the container is not
> already managing an active transaction, i.e.
>
> with DBO_DataModule.IB_Transaction1 do
> begin
> if not TransactionIsActive then
> StartTransaction
> else
> {here you have to deal with the unresolved transaction}.
>
> But there is more trouble here. This looks really weird:
>
> FSQLCommand.InsertSQL.Text := sSQL;
>
> try
>
> FSQLCommand.ExecSQL(ukInsert);
> DBO_DataModule.IB_Transaction1.Commit;
>
> What kind of object is FSQLCommand? What are you trying to do here?
>
> At best, this is some kind of unprepared statement, that throws exception
> because the ???whatever object doesn't know what it is supposed to commit.
>
> Helen
>
>
>
>
> __________________________________________________________________
> _________
> IB Objects - direct, complete, custom connectivity to Firebird or
> InterBase
> without the need for BDE, ODBC or any other layer.
> __________________________________________________________________
> _________
> http://www.ibobjects.com - your IBO community resource for Tech
> Info papers,
> keyword-searchable FAQ, community code contributions and more !
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>
> __________________________________________________________________
> _________
> IB Objects - direct, complete, custom connectivity to Firebird or
> InterBase
> without the need for BDE, ODBC or any other layer.
> __________________________________________________________________
> _________
> http://www.ibobjects.com - your IBO community resource for Tech
> Info papers,
> keyword-searchable FAQ, community code contributions and more !
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>