[英]PLS-00222: no function with name 'INFO_TYPE' exists in this scope
[英]Oracle - no function with name X exists in this scope
该函数显然存在,因为我可以使用SQL Developer导航到它并且它编译得很好,但是当我尝试使用带或不带“call”的函数时,它抛出:
错误(36,24):PLS-00222:此范围内不存在名称为“x”的函数
这是函数的样子:
create or replace function testfunction
(
somevalue in varchar2
)
return varchar2
AS
cursor testcursor IS
select column1, column2 from table1 t
where t.column1 = somevalue;
testcursorrec testcursor %rowtype;
messaget VARCHAR2(500);
begin
open testcursor ;
fetch testcursor into testcursorrec ;
close testcursor ;
messaget := testcursor.column1;
return messaget ;
end;
这就是我所说的:
messaget := testfunction(somevalue);
其中messageT和somevalue都声明为varchar2类型。
游标内部不允许使用游标吗?
错误将是messaget := testcursor.column1;
当光标被关闭时(你应该使用testcursorrec.column2
。
你的代码没有检查没有行,也没有重复行。 你可以简化这个
create or replace function testfunction
(
somevalue in table1.column1%type
)
return table1.column2%type
AS
messaget table1.column2%type; -- use %type where possible.
begin
select t.column2
into messaget
from table1 t
where t.column1 = somevalue
and rownum = 1;--only if you dont care if theres 2+ rows.
return messaget;
exception
when no_data_found
then
return null; -- if you want to ignore no rows.
end;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.