Está en la página 1de 1

DELIMITER $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `producto_nuevo`( in nom varchar(100), in precio double, in stck int, in idc int, in idpv int)

BEGIN declare van int; declare idp int; declare nombre varchar(100); set van =0; set nombre=''; select max(idproducto) into idp from producto; start transaction; while van<=idp do if (van<=idp)then select producto.nombre into nombre from producto where idproducto=van; if (nom=nombre) then set van=idp+1; end if; else set van=idp+1; end if; set van =van+1; end while; select nombre; if (nom=nombre) then update producto set stock=stock+stck where idproducto=idp; else insert into producto values(idp+1,nom,precio,stck,idc,idpv); end if; commit; END$$

También podría gustarte