0

I am trying to define stored procedure in mysql but getting error i am unable to understand what i am doing wrong.

CREATE PROCEDURE distance(lat1 Float,long1 Float,lat2 Float,long2 Float,OUT distance Float)
BEGIN

    SET distance =  ROUND((ACOS(SIN(RADIANS(lat1))*SIN(RADIANS(lat2))+COS(RADIANS(lat1))*COS(RADIANS(lat2))*COS(RADIANS(lon2-lon1)))*6371), 2);

END

ERROR:

#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 '' at line 4

1 Answer 1

3

Use Delimiters to resolve this:

delimiter //
CREATE PROCEDURE distance(lat1 Float,long1 Float,lat2 Float,long2 Float,OUT distance Float)
BEGIN

    SET distance =  ROUND((ACOS(SIN(RADIANS(lat1))*SIN(RADIANS(lat2))+COS(RADIANS(lat1))*COS(RADIANS(lat2))*COS(RADIANS(lon2-lon1)))*6371), 2);

END //
delimiter ;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.