0
I’m trying to create the following function:
DELIMITER //
FUNCTION DISTANCIA ( lat1 DOUBLE, long1 DOUBLE,  lat2 DOUBLE,  long2 DOUBLE )   RETURNS DOUBLE
DETERMINISTIC
BEGIN
    DECLARE d2r DOUBLE;
    DECLARE dlong DOUBLE;
    DECLARE dlat DOUBLE;
    DECLARE temp_sin DOUBLE;
    DECLARE temp_cos DOUBLE;
    DECLARE temp_cos2 DOUBLE;
    DECLARE temp_sin2 DOUBLE;
    DECLARE a DOUBLE;
    DECLARE c DOUBLE;
    set d2r = 0.017453292519943295769236;
    set dlong = (long2 - long1) * d2r;
    set dlat = (lat2 - lat1) * d2r;
    set temp_sin = sin(dlat/2.0);
    set temp_cos = cos(lat1 * d2r);
    set temp_cos2 = cos(lat2 * d2r);
    set temp_sin2 = sin(dlong/2.0);
    set a = (temp_sin * temp_sin2) + (temp_cos * temp_cos2) * (temp_sin2);
    set c = 2.0 * atan2(sqrt(a), sqrt(1.0 - a));
    return 6368.1 * c;
END //
And this returns to me the following mistake, which could be ?
1064 - You have an error in your SQL syntax; check the manual that Corresponds to your Mariadb server version for the right syntax to use
near 'FUNCTION DISTANCE ( lat1 DOUBLE, long1 DOUBLE, lat2 DOUBLE, long2 DOUBLE ) ' at line 1
The first line there is:
FUNCTION DISTANCIA ( lat1 DOUBLE, long1 DOUBLE,  lat2 DOUBLE,  long2 DOUBLE )   RETURNS DOUBLE
						
putis, truth , vlw.
– Chefe Druida