mysql>
Functions and procedures can call themselves.
mysql>
mysql> delimiter $$
mysql> CREATE FUNCTION factorial(n BIGINT) RETURNS BIGINT
-> BEGIN
-> IF n>=2 THEN
-> RETURN n * factorial(n-1);
-> ELSE
-> RETURN n;
-> END IF;
-> END$$
Query OK, 0 rows affected (0.00 sec)
mysql> delimiter ;
mysql>
mysql>
mysql> SELECT factorial(3);
ERROR 1424 (HY000): Recursive stored functions and triggers are not allowed.
mysql>
mysql> drop function factorial;
Query OK, 0 rows affected (0.00 sec)
|