2
Take the example:
create table time(
id int not null primary key auto_increment,
nome varchar(50) unique
)engine=innodb;
delimiter $$
CREATE PROCEDURE insertteam (nometime varchar(50))
begin
declare continue handler for 1062
select 'vc ja inseriu esse nome anteriormente';
insert into time (id, nome)
values(null, nometime);
end$$
delimiter ;
call insertteam ('BRASIL');
select * from time;
If I "call" and insert brazil Again it hangs correctly, until then everything ok. But when I insert a team that does not exist yet it inserts correctly, but skips the ids on the respective times I tried to insert brazil again and went wrong.
For example: if I try to insert brazil 5 times it inserts the first and the error in the others. But then when I insert "Mexico" it inserts correctly but in id = 6.
There is a similar question in SO.en: https://stackoverflow.com/q/16582704/540552
– Victor Stafusa