I am trying to create a stored procedure in MySQL Community Server 5.5.32 version but I procedure returns an error in the first line but I can not find it. Can anyone help me?
CREATE PROCEDURE nearestPanel (IN mylat DOUBLE, IN mylon DOUBLE)
BEGIN
DECLARE dist DOUBLE DEFAULT 62.14;
DECLARE lon1 DOUBLE DEFAULT 0;
DECLARE lon2 DOUBLE DEFAULT 0;
DECLARE lat1 DOUBLE DEFAULT 0;
DECLARE lat2 DOUBLE DEFAULT 0;
DECLARE today TIMESTAMP DEFAULT CURRENT_DATE;
SET lon1 = mylon-dist/abs(cos(radians(mylat))*69);
SET lon2 = mylon+dist/abs(cos(radians(mylat))*69);
SET lat1 = mylat-(dist/69);
SET lat2 = mylat+(dist/69);
SELECT
panels.name,
panels.description,
cells.*,
3956 * 2 * ASIN(SQRT(POWER(SIN((mylat - panels.latitude) * pi()/180 / 2), 2) +COS(mylat * pi()/180) * COS(panels.latitude * pi()/180) * POWER(SIN((mylon -panels.longitude) * pi()/180 / 2), 2))) AS distance
FROM
cells
INNER JOIN
panels
ON
cells.panel_id = panels.id
WHERE
panels.longitude BETWEEN lon1 AND lon2
AND
panels.latitude BETWEEN lat1 AND lat2
AND
today BETWEEN panels.date_start AND panels.date_end
HAVING
distance < dist
ORDER BY
distance LIMIT 1;
END
//as delimiter. Try just first typingdelimiter //, and add your procedure with a//after the last line. Then you can givedelimiter ;to go back to a semicolon delimiter.