Error Pls-00313 Not Declared In This Scope
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring forward declaration in oracle package developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask what is meant by forward declaration and where we'll use it Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join package specification without body oracle them; it only takes a minute: Sign up Procedure in package specification up vote 9 down vote favorite 1 I have a package named save_db_values I have two procedures named store_records and another one called db_activities. db_activities will be
What Are Actual And Formal Parameters In Oracle
called from my application by passing all values in db_activities I will be calling store_records procedure to do insert and delete. Do I need to define store_records procedure in package specification? When I did not define store_records in specification I am getting error store_records not declared in this scope. store_records procedure I do not want to expose and hence I did not add in specification. How can I resolve this issue? oracle stored-procedures plsql scope package share|improve this question forward reference in pl/sql edited Oct 3 '12 at 14:35 APC 87.1k1384184 asked Oct 3 '12 at 11:06 user75ponic 5,85833116208 add a comment| 2 Answers 2 active oldest votes up vote 22 down vote accepted If you do not want some procedures to be publicly available you may not to declare them in the package specification. Declare them only in the package body. The cause of the error you are facing is declaration order of the procedures in the package body or lack of forward declaration. For example: create or replace package Test_pkg as 2 procedure Proc1; 3 end; 4 / Package created create or replace package body Test_pkg as 2 3 procedure proc1 is 4 begin 5 proc2; 6 end; 7 8 procedure Proc2 is 9 begin 10 dbms_output.put_line('proc2 is being executed'); 11 end; 12 13 end; 14 / Warning: Package body created with compilation errors Error: PLS-00313: 'PROC2' not declared in this scope This is happening because we are calling Proc2 which declared later in the package. In this case our choices are: Declare pro2 before the procedure which calls it create or replace package body Test_pkg as 2 3 4 procedure Proc2 is 5 begin 6 dbms_output.put_line('proc2 is being executed'); 7 end; 8 9 procedure proc1 is 10 begin 11 proc2; 12 end; 13 14 end; 15 / Package body created Use forward declaration. create or replace package body Test_pkg as 2 3 procedure Proc2; 4
is not used yet. (Heh, heh, that"s a joke, son.) Action: none PLS-00102: parser stack overflow because nesting is too deep Cause: The parser, which checks procedure in package specification but not in package body the syntax of PL/SQL statements, uses a data structure called a stack; the
Can We Have A Procedure In Specification But Not In Package Body
number of levels of nesting in the PL/SQL block exceeded the stack capacity. Action: Reorganize the block structure to avoid
How To Execute A Procedure Inside A Package In Oracle
nesting at too deep a level. For example, move the lowest-level sub-block to a higher level. PLS-00103: %s Cause: This error message is from the parser. It found a token (language element) http://stackoverflow.com/questions/12707204/procedure-in-package-specification that is inappropriate in this context. Action: Check previous tokens as well as the one given in the error message. The line and column numbers given in the error message refer to the end of the faulty language construct. PLS-00104: empty argument list in call of procedure "string" must be omitted Cause: In a subprogram call, the name of the subprogram was followed by https://docs.oracle.com/cd/B19306_01/server.102/b14219/plsus.htm an empty parameter list. For example, procedure P was called as P(). This is not allowed. Action: Remove the empty parameter list. In the example, change the procedure call to P. PLS-00105: at most one forward declaration of type "string" is permitted Cause: More than one forward declaration of a type is redundant. Action: Remove all but one forward declaration. PLS-00108: declarative units must be a single variable declaration Cause: While checking a declarative unit (a top-level declare block without the BEGIN...END), PL/SQL found that there was more than one item declared or that the item was not a variable declaration. A table is a common variable declaration at the unit level. To define a TABLE, compile a DECLARE compilation unit, but only one at a time is allowed. Action: Declare variables in separate declarative units. PLS-00109: unknown exception name "string" in PRAGMA EXCEPTION_INIT Cause: No declaration for the exception name referenced in an EXCEPTION_INIT pragma was found within the scope of the pragma. Action: Make sure the pragma follows the exception declaration and is within the same scope. PLS-00110: bind variable "string" not allowed in this context Cause: A bind
PLS-00313: 'XXXXX' not declared in this scope 2013-05-17 17:11 3141人阅读 评论(0) 收藏 举报 本文章已收录于: 分类: SQL or PL/SQL(22) 作者同类文章X 版权声明:转载请以链接形式注明出处 Package中私有的Procedure/Function(没在Package Specification声明)需要注意放置的位置比如下面的Package,Procedure A http://blog.csdn.net/pan_tian/article/details/8941036 想要调用 Procedure B,CREATE OR REPLACE PACKAGE AAAAA http://chrishritzuk.blogspot.com/2012/01/procedure-dependencies-in-package.html 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 in oracle AAAAA;会报错:PLS-00313: 'B' not declared in this scope原因: B不是Public的Procedure,如果A想调用B,那么B的定义必须放在A的前边。PLS-00313: "string" not declared in this scopeCause: There is no declaration for the given identifier within the scope of reference. The identifier might be misspelled, its declaration might be specification but not 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 顶 0 踩 0 上一篇SQL Joins 下一篇EBS Forms中焦点丢失的问题 我的同类文章 SQL or PL/SQL(22) http://blog.csdn.net 参考知识库 更多资料请参考: 猜你在找 查看评论 * 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场 个人资料 pan_tian 访问:3412872次 积分:41057 等
that should not have been public. When I asked why this was done the reply was that the procedures had dependencies on one another and the package body would not compile otherwise. Here's a quick demonstration of the issue the developer was encountering. Take a look at the following package specification and body. SQL> CREATE OR REPLACE PACKAGE testpkg AS 2 PROCEDURE proc_main(integer_in IN PLS_INTEGER); 3 END testpkg; 4 / Package created. SQL> CREATE OR REPLACE PACKAGE BODY testpkg AS 2 PROCEDURE proc1_calls_proc2(integer_in IN PLS_INTEGER) IS 3 BEGIN 4 IF integer_in = 0 THEN 5 DBMS_OUTPUT.PUT_LINE('Done!'); 6 ELSE 7 DBMS_OUTPUT.PUT_LINE('integer_in = '||integer_in); 8 proc2_calls_proc1(integer_in - 1); 9 END IF; 10 END proc1_calls_proc2; 11 12 PROCEDURE proc2_calls_proc1(integer_in IN PLS_INTEGER) IS 13 BEGIN 14 IF integer_in = 0 THEN 15 DBMS_OUTPUT.PUT_LINE('Done!'); 16 ELSE 17 DBMS_OUTPUT.PUT_LINE('integer_in = '||integer_in); 18 proc1_calls_proc2(integer_in - 1); 19 END IF; 20 END proc2_calls_proc1; 21 22 PROCEDURE proc_main(integer_in IN PLS_INTEGER) IS 23 BEGIN 24 proc1_calls_proc2(integer_in); 25 END proc_main; 26 END testpkg; 27 / Warning: Package Body created with compilation errors. SQL> SHOW ERRORS Errors for PACKAGE BODY TESTPKG: LINE/COL ERROR -------- ----------------------------------------------------------------- 8/7 PL/SQL: Statement ignored 8/7 PLS-00313: 'PROC2_CALLS_PROC1' not declared in this scope SQL> As you can see, we encounter an error at line 8 in the package body because the procedure proc1_calls_proc2 contains a reference to proc2_calls_proc1 but proc2_calls_proc1has not been declared above it. We could move proc2_calls_proc1above proc1_calls_proc2but we'd encounter the same problem because both procedures reference each other. Like the developer had done we could declare proc2_calls_proc1in the package specification but then we'd be exposing a private procedure to the public and we want to avoid that. The solution to this is that you can pre-declare any of your procedures/functions in a package body at the top of the package body. This way the definitions for all of your methods are available to all other metho