【Oracle】创建function报错,Function created with compilation errors ,PLS-00410;

【Oracle】创建function报错,Function created with compilation errors ,PLS-00410;
创建了一个function,原代码如下:

create or replace function demoinfo (idp in char,minAge out char,maxAge out char)
return char
as
minAge char(10);
begin
select min(age) into minAge from demo where id = idp;
select max(age) into maxAge from demo where id = idp;
return (minAge);
end;
/

创建过程中报错Function created with compilation errors;
使用

show errors function 

可以查看具体的报错信息,报错信息如下:

Errors for function ...
1/1 PLS-00410:RECORD,TABLE 或参数列表中的字段不允许重复
0/0 PL/SQL:compilation unit analysis terminated

观察了下,发现minAge定义了2次:
1、是从demoinfo方法的括号里minAge out char定义了;
2、是方法后面又定义了返回值:return char as minAge char(10);

所以将方法内括号里的minAge的定义删掉即可;

create or replace function demoinfo (idp in char,maxAge out char)
return char
as
minAge char(10);
begin
select min(age) into minAge from demo where id = idp;
select max(age) into maxAge from demo where id = idp;
return (minAge);
end;
/

运行,得到Function created;

猜你喜欢

转载自blog.csdn.net/River_Continent/article/details/81217593
今日推荐