功能创建时编译错误成功,为什么?

时间:2016-12-07 11:46:31

标签: oracle plsql oracle-apex oracle-apex-5

我尝试在Oracle Apex 5,SQL命令中创建此功能,并导致此错误' ORA-24344:编译错误成功。'你为什么这么认为?我试图创建一个随机生成的代码。

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

1 个答案:

答案 0 :(得分:1)

语法错误,见下文

正确的语法是

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