I am trying to use a declare [variable]
statement within a CREATE FUNCTION
statement.
My code is
/* DELIMITER // */
CREATE FUNCTION hello_world()
RETURNS TEXT
DECLARE bae int;
BEGIN
RETURN 'Hello World';
END;
//
/* DELIMITER ; */
The code just worked fine without using declare, but with the declare it gives me the error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use...
How can I actually use the declare statement inside function or stored procedure?