DELIMITER $$
DROP PROCEDURE IF EXISTS `MIBaseDeDatos`.`Insertar` $$
CREATE PROCEDURE `MIBaseDeDatos`.`Insertar` (cod int,cant int)
BEGIN
if exists(select Cod from Tabla1 t where t.Cod=cod)then
update Tabla1 t set Cantidad = Cantidad + cant where t.Cod =cod;
else
insert into Tabla1 values (cod, cant);
end if;
END $$
DELIMITER ;