May 2020
Beginner
564 pages
14h 9m
English
The syntax to create a function is quite similar to creating a stored procedure:
DELIMITER $$ CREATE FUNCTION functionname( parameter1, parameter2,… ) RETURNS datatype [NOT] DETERMINISTIC BEGIN -- put sql statements here END $$ DELIMITER ;
DELIMITER lets MySQL know that there may be lines in-between the delimiter statements that end in a semicolon. If you don't put DELIMITER around a function, you will get an error when MySQL hits the semicolon in your first SQL query, inside the stored procedure.
A function can be deterministic or non-deterministic. Deterministic always returns the same result for the same input parameters, whereas non-deterministic doesn't.
Let's walk through an example. You can ...
Read now
Unlock full access