2
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
數據庫用戶:horizon_jake爲什麼這個查詢沒有執行?
MySQL版本:56年5月1日
錯誤信息
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
你是在MySQL命令行客戶端上執行此操作還是像PHPMyAdmin? 'DELIMITER'是命令行客戶端的一個功能。 –
@Michael:當然phpMyAdmin不會奇蹟般地重新發明MySQL命令界面;它將查詢和命令傳遞給MySQL。 –
@ TomalakGeret'kal PHPMyAdmin有一個單獨的輸入欄來設置分隔符。看到http://stackoverflow.com/questions/2068331/mysql-phpmyadmin-freezes-from-delimiter和其他... –