它表示使用编译错误创建的过程。
B
答案 0 :(得分:0)
相当多的语法错误;将您的代码与我的代码进行比较,找出差异:
SQL> set serveroutput on
SQL> CREATE OR REPLACE PROCEDURE fact (n IN NUMBER, r OUT NUMBER)
2 AS
3 I NUMBER := n;
4 f NUMBER := 1;
5 BEGIN
6 WHILE (i > 1)
7 LOOP
8 f := f * i;
9 i := i - 1;
10 END LOOP;
11
12 r := f;
13 END fact;
14 /
Procedure created.
SQL>
SQL> DECLARE
2 l_out NUMBER;
3 BEGIN
4 fact (4, l_out);
5 DBMS_OUTPUT.put_line (l_out);
6 END;
7 /
24
PL/SQL procedure successfully completed.
SQL>
虽然,你为什么选择创建一个程序?在这种情况下,函数可能更合适:
SQL> CREATE OR REPLACE FUNCTION f_fact (n IN NUMBER)
2 RETURN NUMBER
3 IS
4 i NUMBER := n;
5 f NUMBER := 1;
6 BEGIN
7 WHILE (i > 1)
8 LOOP
9 f := f * i;
10 i := i - 1;
11 END LOOP;
12
13 RETURN f;
14 END;
15 /
Function created.
SQL>
SQL> SELECT f_fact (4) FROM DUAL;
F_FACT(4)
----------
24
SQL>