mySQL DELIMITER throwing 1064
DELIMITER $$
DROP PROCEDURE IF EXISTS eventsNearMe$$
CREATE PROCEDURE eventsNearMe(IN inIP VARCHAR(16))
BEGIN
DECLARE ipLAT FLOAT;
DECLARE ipLONG FLOAT;
SELECT iplocationdb_location.latitude, iplocationdb_location.longitude
INTO ipLAT, ipLONG
FROM `iplocationdb_ip`
LEFT JOIN iplocationdb_location ON iplocationdb_location.id=iplocationdb_ip.location_id
WHERE iplocationdb_ip.prefix=(INET_ATON(inIP)>>24)
AND INET_ATON(inIP) BETWEEN iplocationdb_ip.start_ip AND iplocationdb_ip.end_ip LIMIT 1;
CREATE TEMPORARY TABLE tempEVENTS
SELECT `eid`,(((acos(sin((ipLAT*pi()/180)) * sin((`lat`*pi()/180))+cos((ipLAT*pi()/180)) * cos((`lat`*pi()/180)) * cos(((ipLONG- `long`)*pi()/180))))*180/pi())*60*1.1515) as d FROM `mke_events` HAVING `d` <= 10 LIMIT 1;
SELECT * FROM tempEVENTS;
DROP TEMPORARY TABLE tempEVENTS;
END
$$
DELIMITER ;
The above code should, by my understanding, create a quick little sp to get events near a given ip address. H开发者_StackOverflow中文版owever through all my searching I haven't found a satisfactory reason for it to be throwing 1064 on DELIMITER (line 1).
Even if I have JUST:DELIMITER $$
SELECT * FROM iplocationdb_location;
$$
DELIMITER ;
It still fires 1064. mySQL version 5.0.77.
NOTE: I DO have my space between DELIMITER and the delimiting string. NOTE2: I am using heidiSQL to run this script, which should be tantamount to running it from the command line by my understanding.
I also was getting spurious DELIMITER-related syntax errors, with command-line mysql but not with HeidiSQL, due to extra trailing whitespace (tab characters) on the DELIMITER line. Eg:
DELIMITER ;<TAB><TAB>
Removing the trailing whitespace fixed it (your comment about whitespace tipped me off, thank you.)
精彩评论