2020/07/16

遞迴應用範例

DECLARE
  vInteger PLS_INTEGER := 3;
  
  FUNCTION FnRecursive(pInteger IN NUMBER) RETURN NUMBER IS
    vTotal NUMBER := 0;
  BEGIN
    vTotal := vTotal + pInteger;
    IF pInteger > 0 THEN
      vTotal := vTotal + FnRecursive(pInteger - 1);
    END IF;
    RETURN(vTotal);
  END FnRecursive;
BEGIN
  dbms_output.put_line(FnRecursive(vInteger));
END;

沒有留言: