Ver Mensaje Individual
  #14  
Antiguo 23-06-2022
cloayza cloayza is offline
Miembro
 
Registrado: may 2003
Ubicación: San Pedro de la Paz, Chile
Posts: 913
Reputación: 23
cloayza Tiene un aura espectacularcloayza Tiene un aura espectacular
Propongo esta opción...Procedimiento almacenado en firebird

Código SQL [-]
reate or alter procedure check_correlativos
returns (id_falta integer)
as
declare variable id integer;
declare variable id_next integer;
declare variable oldNext integer;
BEGIN
     OldNext=-1;
     FOR
       select c.id, c.id+1
       from articulos c
       INTO :ID, :ID_NEXT
     DO
     BEGIN
          id_falta=null;
          if (OldNext=-1) then
             OldNext=ID;
   
          if (OldNext<>id) then
             id_falta=OldNext;
   
          OldNext=ID_NEXT;
   
          if (not id_falta is null) then
             suspend;
     END
END
Responder Con Cita