SQL Oracle 错误 PLS-00323:子程序或游标在包规范中声明,必须在包体中定义
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26525204/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Oracle Error PLS-00323: subprogram or cursor is declared in a package specification and must be defined in the package body
提问by SqlNoob
Can someone help me put my pl/sql procedure in a package? I've tried and I'm struggling with it:
有人可以帮我把我的 pl/sql 程序放在一个包里吗?我已经尝试过并且正在努力解决它:
This is what I have, for my package specification:
对于我的包装规格,这就是我所拥有的:
CREATE OR REPLACE PACKAGE film_pkg
IS
title VARCHAR2(100);
PROCEDURE get_films(fname VARCHAR2);
END film_pkg;
--
This is my package body where im running into the problems:
这是我遇到问题的包体:
CREATE OR REPLACE PACKAGE BODY film_pkg
IS
PROCEDURE get_films (fname IN film.title%TYPE,
r_date OUT film.release_date%TYPE,
dur OUT film.duration%TYPE)
AS
BEGIN
SELECT release_date, duration
INTO r_date, dur
FROM FILM
WHERE title = fname;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
r_date := '';
dur := '';
END get_films;
END film_pkg;
if anyone could help me fix the errors i'd appreciate it:
如果有人可以帮助我修复错误,我将不胜感激:
Error(4,11): PLS-00323: subprogram or cursor 'GET_FILMS' is declared in a package specification and must be defined in the package body
回答by StuartLC
Your header and body procedure definitions don't match
您的标题和正文过程定义不匹配
In the header, you have:
在标题中,您有:
PROCEDURE get_films(fname VARCHAR2);
Whereas in the body:
而在体内:
PROCEDURE get_films(fname IN film.title%type,
r_date OUT film.release_date%type, dur OUT film.duration%type)
You probably just need to update the header definition with the two additional OUT params?
您可能只需要使用两个额外的 OUT 参数更新标头定义?
To Summarize
总结
- Ensure the header definition matches all parameters of the body implementation (number of parameters, names of parameters, order of parameters, and the parameter types)
- As per Alex's comment, do not mix and match the custom type (
film.title%type
) with the base type (VARCHAR2
). Choose one or the other.
- 确保标头定义匹配主体实现的所有参数(参数数量、参数名称、参数顺序和参数类型)
- 根据 Alex 的评论,不要将自定义类型 (
film.title%type
) 与基本类型 (VARCHAR2
)混合和匹配。选择其中之一。
回答by Sithija Piyuman Thewa Hettige
"subprogram or cursor 'M115_EDIT' is declared in a package specification and must be defined in the package body"
“子程序或光标‘M115_EDIT’在包规范中声明,必须在包体中定义”
I got this error while i was working on my project.the reason for this was the a parameter name that was inside the procedure defined in the body did not match with the corresponding parameter name in the body.
我在处理项目时遇到此错误。原因是主体中定义的过程中的参数名称与主体中的相应参数名称不匹配。
my market_code parameter is different in the body when compared with the specification where it is defined as sub_market_code.error occurred due to this difference. i changed the sub_market_code parameter in the specification to market_code so that it matches with the body and this solved the problem mentioned above.
与定义为 sub_market_code.error 的规范相比,我的 market_code 参数在正文中有所不同。我将规范中的 sub_market_code 参数更改为 market_code,使其与正文匹配,从而解决了上述问题。
clearly 2 parameters that are mentioned in your body implementation of the procedure 'r_date' and 'dur' are not defined in the specification.error is due to this difference between the body and the specification.
很明显,规范中没有定义过程“r_date”和“dur”的主体实现中提到的 2 个参数。错误是由于主体和规范之间的这种差异。
回答by Khang Dq
"parameter namethat was inside the procedure defined in the body did not match with the corresponding parameter name in the body."
“参数名称,这是在体内定义并没有在身体相应的参数名称相匹配的过程中。”