Subject | Re: Exception question |
---|---|
Author | johnsparrowuk |
Post date | 2004-03-21T18:51:51Z |
Hi Dan,
I don't follow you - the code I quoted was FB sproc code (sorry, I
didn't say explicitly) so I can't have a transaction rollback in the
exception handler! You can't begin, commit or rollback transactions
in stored procedures or triggers (unless things have changed *very*
radically while I've been away!).
They rely on exception handling and undoing to maintain atomicity.
Transactions are started and ended by client (code) request.
Anyway, I've been playing since I wrote that message, and answered
my own question, it would undo the insert in:
including the begin...end block in which you catch it. Everything
else is left as-is.
'Rollback' without rollback, cool eh?? ;)
Thanks,
John
--- In firebird-support@yahoogroups.com, "Dan Wilson" <dwilson@d...>
wrote:
including the insert. Note that actions outside of transaction
scope, such as generator increments, will not be undone. It all
depends on what you decide to do in your exception code.
I don't follow you - the code I quoted was FB sproc code (sorry, I
didn't say explicitly) so I can't have a transaction rollback in the
exception handler! You can't begin, commit or rollback transactions
in stored procedures or triggers (unless things have changed *very*
radically while I've been away!).
They rely on exception handling and undoing to maintain atomicity.
Transactions are started and ended by client (code) request.
Anyway, I've been playing since I wrote that message, and answered
my own question, it would undo the insert in:
> > begin*/
> > insert into mytable values ('a');
> > execute procedure xx; /* xx throws exception, insert is undone
> > when any doIf I didn't want the insert to be undone, I should do something like:
> > begin
> > ...
> > end
> > end!!
> > beginBasically, if you catch an exception, it will undo upto and
> > insert into mytable values ('a'); /* not undone */
> > BEGIN
> > insert into mytable values ('b'); /* is undone */
> > execute procedure xx; /* xx throws exception */
> > when any do
> > begin
> > ...
> > end
> > END
> > end!!
including the begin...end block in which you catch it. Everything
else is left as-is.
'Rollback' without rollback, cool eh?? ;)
Thanks,
John
--- In firebird-support@yahoogroups.com, "Dan Wilson" <dwilson@d...>
wrote:
>rollback, then everything in the transaction context will be undone,
>
> if the actions in your exception code include a transaction
including the insert. Note that actions outside of transaction
scope, such as generator increments, will not be undone. It all
depends on what you decide to do in your exception code.
> > If I have code something like:undo
>
> > begin
> > insert into mytable values ('a');
> > execute procedure xx; /* xx might throw exception */
> > when any do
> > begin
> > ...
> > end
> > end!!
>
> > and sproc 'xx' does throw an exception, will it automatically
> > actions performed in 'xx' even though the exception is beinghandled
> > one block up?
>
> > Would it undo the 'insert...'?