PLS-00313: 'XXXXX' not declared in this scope

來源:互聯網
上載者:User
Package中私人的Procedure/Function(沒在Package Specification聲明)需要注意放置的位置

比如下面的Package,Procedure A 想要調用 Procedure B,
CREATE OR REPLACE PACKAGE AAAAA AUTHID CURRENT_USER AS  PROCEDURE A;END AAAAA;
CREATE OR REPLACE PACKAGE BODY AAAAA AS  PROCEDURE A IS  BEGIN    B;  END;  PROCEDURE B IS  BEGIN    dbms_output.put_line('In PROCEDURE B');  END ;END AAAAA;
會報錯: PLS-00313: 'B' not declared in this scope


原因: B不是Public的Procedure,如果A想調用B,那麼B的定義必須放在A的前邊。

PLS-00313: "string" not declared in this scope
Cause: There is no declaration for the given identifier within the scope of reference. The identifier might be misspelled, its declaration might be faulty, or the declaration might be placed incorrectly in the block structure.
Action: Check the spelling and declaration of the identifier. Also confirm that the declaration is placed correctly in the block structure.

所以正確的寫法是:

CREATE OR REPLACE PACKAGE BODY AAAAA AS  PROCEDURE B IS  BEGIN    dbms_output.put_line('In PROCEDURE B');  END ;   PROCEDURE A IS  BEGIN    B;  END; END AAAAA;
或者,如果確實想把B放到後邊,那麼可以在前面聲明下,這樣後邊不過誰調用,也不會報錯,這也是一個很好的習慣。
CREATE OR REPLACE PACKAGE BODY AAAAA AS  PROCEDURE B;   PROCEDURE A IS  BEGIN    B;  END;  PROCEDURE B IS  BEGIN    dbms_output.put_line('In PROCEDURE B');  END ;END AAAAA;


Reference:http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:11471812249709


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.