Oracle – 此范围内不存在名称为X的函数
发布时间:2021-01-13 06:54:06 所属栏目:站长百科 来源:网络整理
导读:该函数显然存在,因为我可以使用SQL Developer导航到它并且它编译得很好,但是当我尝试使用带或不带“call”的函数时,它抛出: Error(36,24): PLS-00222: no function with name ‘x’ exists in this scope 这是函数的样子: create or replace function test
该函数显然存在,因为我可以使用SQL Developer导航到它并且它编译得很好,但是当我尝试使用带或不带“call”的函数时,它抛出:
这是函数的样子: 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; (编辑:威海站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |