MySQL Forums
Forum List  »  Stored Procedures

Re: Transactions: how to handle a rollback.
Posted by: gustavo bellino
Date: November 03, 2005 06:19PM

you can also declare an out parameter
for example

drop procedure if exists EditarMarca/
create procedure EditarMarca(
in id_var int(11),
in newNomMarca char(15),
out res char(8))
begin
DECLARE exit handler for 1062 rollback;
set res:='error';
start transaction;
update marcaProd set nomMarca=newNomMarca where idMarca=id_var;
commit;
set res:='ok';
end/

when you have an error the handler goes out the SP and you have the string 'error' in the out parameter and you will know if it did it ok or not
that SP works



Edited 1 time(s). Last edit at 11/03/2005 06:20PM by gustavo bellino.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Transactions: how to handle a rollback.
1769
November 03, 2005 06:19PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.