Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL error #1064 on create function

Tags:

mysql

Here is my code:

create function getten() returns integer
begin
return 10;
end

giving me error message:

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 3 

I have no idea what the '' is all about. Any help please?

like image 324
more2chance Avatar asked Nov 24 '25 00:11

more2chance


2 Answers

First of all, SQL code is written in big letters. Second, please remember indention.

DELIMITER $$
CREATE FUNCTION getten()
  RETURNS INTEGER
  LANGUAGE SQL
BEGIN
  RETURN 10;
END;
$$
DELIMITER ;

should work like this.

like image 127
Xatenev Avatar answered Nov 26 '25 13:11

Xatenev


This works for me...

DELIMITER $$
 CREATE FUNCTION getten()
  RETURNS INTEGER
  BEGIN
  RETURN 10;
  END;
 $$

DELIMITER ;

SELECT getten();
+----------+
| getten() |
+----------+
|       10 |
+----------+
like image 43
Strawberry Avatar answered Nov 26 '25 13:11

Strawberry