0

I am getting a syntax error with this simple sample script in MySql 5.6.17 :

CREATE FUNCTION sampldb.fn_x(param VARCHAR(20))
RETURNS int
BEGIN
return 1;
END

What am i doing wrong? In Sql workbench, the error is shown in the last 2 lines.

3
  • and what is the error? Commented May 18, 2014 at 6:27
  • Put a ; at end end; Commented May 18, 2014 at 6:30
  • It's just a generic syntax error. "You have an error in your SQL syntax. Check the manual...". Putting an ; at end makes no difference. Commented May 18, 2014 at 6:31

1 Answer 1

3

use DELIMITER

DELIMITER //
CREATE FUNCTION sampldb.fn_x(param VARCHAR(20))
RETURNS int
BEGIN
return 1;
END
//
Sign up to request clarification or add additional context in comments.

2 Comments

And still use a semicolon after the END, some versions are sensitive about that.
DELIMITER did the trick! I mistakenly assumed that was required only when executing in the MySql monitor, and not in the workbench. I didn't need the ;

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.