Ver Mensaje Individual
  #10 (permalink)  
Antiguo 09/06/2009, 02:16
Tucky5
 
Fecha de Ingreso: mayo-2009
Ubicación: Valencia
Mensajes: 18
Antigüedad: 15 años, 9 meses
Puntos: 0
Respuesta: Trigger para sumar 1 después de insertar

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '&&
CREATE TRIGGER sumahabitacion
AFTER INSERT ON habitaciones
FOR EACH ROW
' at line 3

Sí, puse los delimitadores:
DELIMITER&&
CREATE TRIGGER sumahabitacion
AFTER INSERT ON habitaciones
FOR EACH ROW
BEGIN
if NEW.Tipo='Simple'
THEN UPDATE alojamientos
SET Simples=(Simples+1) WHERE identificador=NEW.idHotel;
else UPDATE alojamientos
SET Dobles=(Dobles+1) WHERE identificador NEW.idHotel;
END if;
END&&
DELIMITER;

Y si le quito los delimitadores, me da otro error:
Can't create a TRIGGER from within another stored routine

Última edición por Tucky5; 09/06/2009 a las 02:21