DELIMITER $$
USE `horizon_jake`$$
DROP FUNCTION IF EXISTS `GPS_Distance_Meters`$$
CREATE DEFINER=`horizon_jake`@`localhost` FUNCTION `GPS_Distance_Meters`(lat1 DOUBLE, lng1 DOUBLE, lat2 DOUBLE, lng2 DOUBLE) RETURNS DOUBLE
BEGIN
DECLARE rlo1 DOUBLE;
DECLARE rla1 DOUBLE;
DECLARE rlo2 DOUBLE;
DECLARE rla2 DOUBLE;
DECLARE dlo DOUBLE;
DECLARE dla DOUBLE;
DECLARE a DOUBLE;
SET rlo1 = RADIANS(lng1);
SET rla1 = RADIANS(lat1);
SET rlo2 = RADIANS(lng2);
SET rla2 = RADIANS(lat2);
SET dlo = (rlo2 - rlo1) / 2;
SET dla = (rla2 - rla1) / 2;
SET a = SIN(dla) * SIN(dla) + COS(rla1) * COS(rla2) * SIN(dlo) * SIN(dlo);
RETURN (6378137 * 2 * ATAN2(SQRT(a), SQRT(1 - a)));
END$$
DELIMITER ;
数据库名称:地平线牦牛
数据库用户:horizon jake
MySQL版本:5.1.56
误差测量
Error
SQL query:
DELIMITER $$ USE `horizon_jake` $$ DROP FUNCTION IF EXISTS `GPS_Distance_Meters` $$ CREATE DEFINER = `horizon_jake`@`localhost` FUNCTION `GPS_Distance_Meters` (
lat1 DOUBLE,
lng1 DOUBLE,
lat2 DOUBLE,
lng2 DOUBLE
) RETURNS DOUBLE BEGIN DECLARE rlo1 DOUBLE;
MySQL said: Documentation
#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 'DELIMITER $$
USE `horizon_jake`$$
DROP FUNCTION IF EXISTS ' at line 1
最佳答案
DELIMITER
为SQL语句定义分隔符。USE
不是SQL语句,因此不需要用$$
分隔。
关于mysql - 为什么此查询未执行?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7995789/