Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/11/2011, 04:41
pinchu
 
Fecha de Ingreso: septiembre-2009
Mensajes: 215
Antigüedad: 14 años, 7 meses
Puntos: 1
Sintaxis función mysql

Hola, tengo esta función:

DROP FUNCTION IF EXISTS getDistance;
CREATE FUNCTION getDistance( lat1 FLOAT, lon1 FLOAT, lat2 FLOAT, lon2 FLOAT ) RETURNS int
BEGIN
DECLARE pi, q1, q2, q3 FLOAT;
DECLARE rads FLOAT DEFAULT 0;
SET pi = PI();
SET lat1 = lat1 * pi / 180;
SET lon1 = lon1 * pi / 180;
SET lat2 = lat2 * pi / 180;
SET lon2 = lon2 * pi / 180;
SET q1 = COS(lon1-lon2);
SET q2 = COS(lat1-lat2);
SET q3 = COS(lat1+lat2);
SET rads = ACOS( 0.5*((1.0+q1)*q2 - (1.0-q1)*q3) );
RETURN 6378.388 * rads;
END;

Y me tira el siguiente error:

#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 '' at line 3

¿Alguien me echa un cable? Gracias de antemano