【问题标题】:compile procedure in oracle 11goracle 11g中的编译过程
【发布时间】:2012-09-26 19:09:02
【问题描述】:

我在 oracle 11g 中用客户端松鼠创建了一个简单的程序,这是代码

create or replace procedure EXAMPLE_P is
begin
    1+2;
end;/

在执行时我收到了这个警告

Warning:   Warning: execution completed with warning
SQLState:  99999
ErrorCode: 17110
Position: 0

Query 1 of 1, Rows read: 0, Elapsed time (seconds) - Total: 0.031, SQL query: 0.031, Building output: 0

这里的问题,我不能调用我的程序。

begin
    EXAMPLE_P();
end;/

我在执行上面的代码块时遇到了这个错误。

Error: ORA-06550: line 2, column 9:
PLS-00302: component 'EXAMPLE_P' must be declared
ORA-06550: line 2, column 2:
PL/SQL: Statement ignored

SQLState:  65000
ErrorCode: 6550
Position: 37

该过程存在于表 ALL_OBJECTS 中,状态为 INVALID。 我试图编译它(验证状态),但我不会使用下面的查询

alter procedure EXAMPLE_P COMPILE;

有人知道我可以做些什么来调用我的程序,(我使用 PL/SQL 开发人员,从来没有遇到过这个问题)

【问题讨论】:

    标签: sql oracle procedure squirrel-sql


    【解决方案1】:

    你不能调用你的过程,因为你没有创建它。您没有创建它,因为您没有 1 + 2 的分配目标。你必须声明一个变量才能把它放进去。你也把/放在了错误的地方。

    比较这两者的区别:

    SQL> create or replace procedure EXAMPLE_P is
      2  begin
      3      1+2;
      4  end;/
      5  /
    
    Warning: Procedure created with compilation errors.
    
    SQL> create or replace procedure EXAMPLE_P is
      2    i number; -- Declare a variable
      3  begin
      4      i := 1 + 2; -- assign something to the variable.
      5  end;
      6  /
    
    Procedure created.
    

    然后您错误地调用它。如果您没有参数,则不应包含()

    SQL> begin
      2     example_p;
      3  end;
      4  /
    
    PL/SQL procedure successfully completed.
    
    SQL>
    

    我尝试在 PL/SQL 开发人员中创建您的过程并收到以下错误;所以,我有点惊讶你从来没有遇到过问题。

    PROCEDURE ALERT.EXAMPLE_P 的编译错误

    错误:PLS-00103:在期待其中一个时遇到符号“1” 以下:

       ( begin case declare exit for goto if loop mod null pragma
       raise return select update while with <an identifier>
       <a double-quoted delimited-identifier> <a bind variable> <<
       continue close current delete fetch lock insert open rollback
       savepoint set sql execute commit forall merge pipe purge
    The symbol "return" was substituted for "1" to continue. Line: 3 Text: 1 + 2;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-09
      • 2021-05-22
      相关资源
      最近更新 更多