See 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 locks up correctly, so everything is ok. But when I insert a team that does not yet exist, it inserts correctly, but skips the ids in the respective times that I tried to enter Brazil again and it 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 enter "Mexico" it inserts correctly but not id = 6.