0

im having trouble finding the correct syntax i always having error #1064.

error: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ';

this is the code;

DELIMITER $$

DROP FUNCTION IF EXISTS formula$$

CREATE FUNCTION formula(iq INT, sq INT, ig INT) RETURNS INT

BEGIN

DECLARE result INT;

SET result = (iq-((sq/30)) * ig;

IF result >= 0 THEN
    RETURN result;
ELSEIF result < 0  THEN
    RETURN 0;
END IF;

END; $$

DELIMITER ;

i've searching for the answer in the web nothing i can find. what is the wrong with my syntax?

1 Answer 1

2

you have a very small mistake in the code.

DELIMITER $$

DROP FUNCTION IF EXISTS formula$$

CREATE FUNCTION formula(iq INT, sq INT, ig INT) RETURNS INT

BEGIN

DECLARE result INT;

SET result = (iq-((sq/30))) * ig; ---> You missed an closing bracket (")") here

IF result >= 0 THEN RETURN result; ELSEIF result < 0 THEN RETURN 0; END IF; 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.