oracle PLS-00302:必须声明Le composant 'GEN_BULL_PAY'

ibrsph3r  于 2023-08-03  发布在  Oracle
关注(0)|答案(1)|浏览(96)

我有这个过程,但当我尝试执行它时,它返回给我以下消息:

CREATE OR REPLACE PROCEDURE SCHEMAUSER.GEN_BULL_PAY(p_deadline IN VARCHAR2)
as
BEGIN
    select BULL_ROW
    from SCHEMAUSER.BULL_CP
    where adress is not null and ACCOUNT_TYPE = 'NATIO'
        and TERM = to_date(p_deadline , 'dd/mm/yyyy')
       or (ACCOUNT_TYPE is null or CODE_PAYMENT_METHOD = 'M')
    order by NUM_RCAR, ITEM_ORDER;
    commit;
end;

字符串
执行此查询后:

begin
    SCHEMAUSER.GEN_BULL_PAY;
end;


我明白了

[2023-07-13 15:45:06] [65000][6550]
[2023-07-13 15:45:06]   ORA-06550: Ligne 2, colonne 17 :
[2023-07-13 15:45:06]   PLS-00302: PLS-00302: component 'GEN_BULL_PAY' must be declared
[2023-07-13 15:45:06]   ORA-06550: Ligne 2, colonne 5 :
[2023-07-13 15:45:06]   PL/SQL: Statement ignored
[2023-07-13 15:45:06] Position: 22

yh2wf1be

yh2wf1be1#

首先,程序无效; PL/SQL需要一个INTO子句,而您没有它。

SQL> create or replace procedure scott.gen_bull_pay
  2  as
  3  begin
  4    select loc
  5    from dept
  6    where deptno = 10;
  7  end;
  8  /

Warning: Procedure created with compilation errors.

SQL> show err
Errors for PROCEDURE SCOTT.GEN_BULL_PAY:

LINE/COL ERROR
-------- -----------------------------------------------------------------
4/3      PLS-00428: an INTO clause is expected in this SELECT statement
SQL> begin
  2    scott.gen_bull_pay;
  3  end;
  4  /
  scott.gen_bull_pay;
        *
ERROR at line 2:
ORA-06550: line 2, column 9:
PLS-00302: component 'GEN_BULL_PAY' must be declared
ORA-06550: line 2, column 3:
PL/SQL: Statement ignored

SQL>

字符串
让我们使它有效:

SQL> create or replace procedure scott.gen_bull_pay
  2  as
  3    l_loc dept.loc%type;
  4  begin
  5    select loc
  6    into l_loc
  7    from dept
  8    where deptno = 10;
  9  end;
 10  /

Procedure created.


由于错误,您得到:我怀疑在那个模式中还有一个对象与模式本身同名。例如,一个包:

SQL> show user
USER is "SCOTT"
SQL> create or replace package scott as
  2    c_num number := 0;
  3  end;
  4  /

Package created.


因此,当你通过指定所有者名称(在我的例子中是scott)来调用函数时,Oracle会抱怨,因为在我的例子中,gen_bull_pay不存在于名为scott的包中:

SQL> begin
  2    scott.gen_bull_pay;
  3  end;
  4  /
  scott.gen_bull_pay;
        *
ERROR at line 2:
ORA-06550: line 2, column 9:
PLS-00302: component 'GEN_BULL_PAY' must be declared
ORA-06550: line 2, column 3:
PL/SQL: Statement ignored


如果省略所有者名称,则它可以工作:

SQL> begin
  2    gen_bull_pay;
  3  end;
  4  /

PL/SQL procedure successfully completed.

SQL>


有关更多信息,请查看模式范围中的名称解析

相关问题