0

I want to create a function for calculating the distance between points.

The calculation is going as expected, but i receive an error here:

DROP FUNCTION IF EXISTS CalculateDistance;

CREATE FUNCTION CalculateDistance(breite double, laenge double) RETURNS INT READS SQL DATA

BEGIN

DECLARE breite DOUBLE;

SET @ibk_laenge = breite;

CREATE FUNCTION CalculateDistance(breite double, laenge double) RETURNS INT READS SQL DATA

BEGIN

DECLARE breite DOUBLE

MySQL meldet: Dokumentation 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 5

What's wrong with that?

0

1 Answer 1

1

You need to change the delimiter first:

delimiter //
CREATE FUNCTION CalculateDistance ...

END //
delimiter ;

Otherwise the function definition stops at the first ; which would make it incomplete.

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.