A function that takes a parameter, performs an operation using an SQL function, and returns the result : Function « Procedure Function « MySQL Tutorial






In this case, it is unnecessary to use delimiter because the function definition contains no internal ; statement delimiters:

mysql>
mysql>
mysql> CREATE FUNCTION hello (s CHAR(20)) RETURNS CHAR(50)
    ->     RETURN CONCAT('Hello, ',s,'!');
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql>
mysql> SELECT hello('world');
+----------------+
| hello('world') |
+----------------+
| Hello, world!  |
+----------------+
1 row in set (0.00 sec)

mysql>
mysql>
mysql> drop function hello;
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql>








11.3.Function
11.3.1.Creating Functions
11.3.2.A function that takes a parameter, performs an operation using an SQL function, and returns the result
11.3.3.Single statement function
11.3.4.Nested function call
11.3.5.Using buildin function in user-defined function
11.3.6.Changing and Removing Functions
11.3.7.To remove a stored function, use the DROP command
11.3.8.Create a procedure for 'READS SQL DATA'
11.3.9.ALTER PROCEDURE and ALTER FUNCTION Syntax
11.3.10.DROP PROCEDURE and DROP FUNCTION Syntax
11.3.11.Function Permissions