成功创建函数但出现编译错误,为什么?

success with compilation error on Function creation, why?

我试图在 Oracle Apex 5 中创建这个函数,SQL 命令,结果导致了这个错误 'ORA-24344: success with compilation error.' 你为什么这么认为?我正在尝试创建一个随机生成的代码。

CREATE OR REPLACE FUNCTION generate_code()
    return varchar2
    AS
    code varchar2;
    BEGIN
    code := DBMS_RANDOM.value(1,100);
    return code;
    END;

语法错误,见下文

正确的语法是

CREATE OR REPLACE FUNCTION generate_code

    return varchar2
    AS
    code varchar2(100);
    BEGIN
    code := DBMS_RANDOM.value(1,100);
    return code;
    END;

带有错误描述的原始语法:

SQL> CREATE OR REPLACE FUNCTION generate_code()
  2
  3      return varchar2
  4      AS
  5      code varchar2;
  6      BEGIN
  7      code := DBMS_RANDOM.value(1,100);
  8      return code;
  9      END;
 10
 11  /

Warning: Function created with compilation errors.

SQL> show error
Errors for FUNCTION GENERATE_CODE:

LINE/COL ERROR
-------- -----------------------------------------------------------------
1/24     PLS-00103: Encountered the symbol ")" when expecting one of the
         following:
         <an identifier> <a double-quoted delimited-identifier>
         current delete exists prior