mysql factorial stored procedure example

Solutions on MaxInterview for mysql factorial stored procedure example by the best coders in the world

showing results for - "mysql factorial stored procedure example"
Ewan
27 Mar 2019
1delimiter //
2CREATE PROCEDURE fact(IN x BIGINT)
3BEGIN
4DECLARE result BIGINT;
5DECLARE i BIGINT;
6SET result = 1;
7SET i = 1;
8WHILE i <= x DO
9SET result = result * i;
10SET i = i + 1;
11END WHILE;
12SELECT x AS Number, result as Factorial;
13END//
14delimiter ;