Ver Mensaje Individual
  #4  
Antiguo 07-11-2015
Avatar de Angel.Matilla
Angel.Matilla Angel.Matilla is offline
Miembro
 
Registrado: ene 2007
Posts: 1.350
Reputación: 19
Angel.Matilla Va por buen camino
Me explico mejor. Entiendo que la llamada al procdure sería algo así:
Código PHP:
EXCUTE PROCEDURE GEN_AFILIACION(45); 
Ahora tengo definido un trigger de esta manera:
Código PHP:
CREATE TRIGGER Afiliacion_New_Reg FOR Afiliacion
ACTIVE BEFORE INSERT
  POSITION 0
AS
BEGIN
  
IF (NEW.Codigo IS NULLTHEN 
  
NEW.Codigo GEN_ID(ID_Afiliacion1);
END
Y definiendo el procedure como me has indicado en tu código, ¿el trigger debería quedar así?
Código PHP:
CREATE TRIGGER Afiliacion_New_Reg FOR Afiliacion
ACTIVE BEFORE INSERT
  POSITION 0
AS
BEGIN
  
IF (NEW.Codigo IS NULLTHEN 
  
NEW.Codigo GEN_AFILIACION(45);
END
Pero por lo que llevo leído en los triggers no pueden usarse variables y aquí es donde me pierdo del todo.
Responder Con Cita