Oralce PL/SQL examples of recursion (#91)
This commit is contained in:
committed by
Aditya Bhargava
parent
31412a0b96
commit
ac08df2ee7
22
03_recursion/plsql/01_countdown.sql
Normal file
22
03_recursion/plsql/01_countdown.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
SET SERVEROUTPUT ON
|
||||
DECLARE
|
||||
result NUMBER;
|
||||
|
||||
FUNCTION countdown(x NUMBER)
|
||||
RETURN NUMBER
|
||||
IS
|
||||
f NUMBER;
|
||||
|
||||
BEGIN
|
||||
dbms_output.put_line(x);
|
||||
IF x <= 0 THEN
|
||||
return x;
|
||||
ELSE
|
||||
f := countdown(x - 1);
|
||||
END IF;
|
||||
RETURN f;
|
||||
END;
|
||||
|
||||
BEGIN
|
||||
result := countdown(5);
|
||||
END;
|
||||
Reference in New Issue
Block a user