Ver Mensaje Individual
  #5 (permalink)  
Antiguo 02/05/2014, 10:48
josueruiz91
 
Fecha de Ingreso: mayo-2014
Ubicación: Venezuela
Mensajes: 4
Antigüedad: 10 años
Puntos: 0
Respuesta: Auto-Incrementar Campos en Mysql

Intenté hacerlo a través de un procedimiento almacenado. Nunca había trabajado con algunos. Puedes decirme donde tengo el error? Asi tal cual no me funciona

DROP PROCEDURE IF EXISTS sp_autoincremento;
//
CREATE PROCEDURE sp_autoincremento()
BEGIN
if(exists(select libro,folio,boleta from biblioteca)) them
if(exists(select boleta from bautizo where mod(boleta,2)=0)) them
update bautizo set folio=folio+1;
if(exists(select boleta from bautizo where boleta=6)) them
update bautizo set boleta=1,folio=1,libro=libro+1;
else
update bautizo set boleta=boleta+1;
endif;
else
insert into bautizo(libro,folio,boleta) values(1,1,1);
endif;
END
//