TOPIC: Rollback from a trigger?
#77
Rollback from a trigger? 4 Years, 5 Months ago
Hi, why I can't rollback a transaction from within a trigger? I would like to use a trigger to read some fields from a table and then to compare the values with those from the new record (passed to the trigger function). But, a code like this goes in error when it has to do a rollback:

Trigger_mytable
function(t,oldrec,newrec)
{
//Do some checks...
...
...

if (..checks are ok..)
...do something...
else
t.Rollback()
}

If it isn't possible to do a rollback from within a transaction, then why 't' has to be passed to the trigger function?

Post edited by: Mauro, at: 2006/03/01 19:13
 
 
Mauro
 
#79
Re:Rollback from a trigger? 4 Years, 5 Months ago
t is passed to the trigger so it can be used for any updates that the trigger might do.

I never thought of needing to rollback from a trigger. This is the first request for this.

What happens when you do this?

One issue might be if you are running client-server then triggers run on the server, so you would be rolling back the transaction on the server, but the client would not know about it.

It may not be too hard for me to add this ability.
 
 
andrew
 
#80
Re:Rollback from a trigger? 4 Years, 5 Months ago
andrew wrote:
t is passed to the trigger so it can be used for any updates that the trigger might do.
Then, the transaction t is not commited yet when it is passed to the trigger? This means that, theoretically I should can rollback from it.
I never thought of needing to rollback from a trigger. This is the first request for this.

What happens when you do this?
This is the error when I use t.Rollback() within a trigger:


P.S.: For the above pic I'm using an image hosting site, because the img upload function of this forum is not working for me.

Post edited by: Mauro, at: 2006/03/02 12:08
 
 
Mauro
 
#84
Re:Rollback from a trigger? 4 Years, 5 Months ago
The transaction passed to the trigger is not completed.

But it looks like rollback from trigger is not handled properly.
 
 
andrew