Reputation: 18353
I'm trying to create a MySQL function with multiple inputs, but keep getting an error:
DELIMITER $$
mysql> CREATE FUNCTION jb_test (a CHAR, b CHAR)
-> RETURNS CHAR
-> DETERMINISTIC
-> SET say = CONCAT(a,b);
-> RETURN say;
-> END$$
ERROR 1064 (42000): 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 'FUNCTION jb_test (a CHAR, b CHAR)
RETURNS CHAR
DETERMINISTIC
SET say = CONCAT(a,b' at line 1
Upvotes: 0
Views: 819
Reputation: 167
CREATE FUNCTION jb_test (a CHAR, b CHAR)
RETURNS CHAR
DETERMINISTIC
BEGIN
DECLARE say CHAR;
SET say = CONCAT(a,b);
RETURN say;
END|
Upvotes: 1
Reputation: 20920
The syntax for the function is as follows:
mysql> CREATE FUNCTION function_name (s CHAR(20))
mysql> RETURNS CHAR(50) DETERMINISTIC
-> RETURN CONCAT('Hello, ',s,'!');
The argument is as given below
FUNCTION function_name (s CHAR(20))
FUNCTION sp_name ([func_parameter[,...]])
Refer Mysql Documentation
Upvotes: 0