Bueno la cuestión es que estoy creando una función en mysql y phpmyadmin y al crearla me da un error y he buscado y rebuscado y no he conseguido arreglarlo.
La función es la siguiente:
Código:
Y el error es el siguiente:DROP FUNCTION IF EXISTS ferrerdb.getOcupacion; CREATE FUNCTION xxxx.`getOcupacion`(fecha DATE, hotel int, tipo int) RETURNS int(11) DETERMINISTIC BEGIN DECLARE ocupacion INT; SET ocupacion=0; SELECT SUM(cantidad) INTO ocupacion FROM reservas WHERE id_Hotel=hotel AND tipo_habitacion=tipo AND ((fec_entrada<=fecha) AND (fecha<=fec_salida)); IF ocupacion<=>NULL THEN return 0; ELSE return ocupacion; END IF; END;
#1064 - 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 'int' at line 4
Por lo que veo el error se produce en el DECLARE ocupacion INT;
Haber si alguien me puede ayudar.
Gracias y Felices Fiestas