Oracle – 此范围内不存在名称为X的函数

Oracle – 此范围内不存在名称为X的函数,第1张

概述该函数显然存在,因为我可以使用SQL Developer导航到它并且它编译得很好,但是当我尝试使用带或不带“call”的函数时,它抛出: Error(36,24): PLS-00222: no function with name ‘x’ exists in this scope 这是函数的样子: create or replace function testfunction ( so 该函数显然存在,因为我可以使用sql Developer导航到它并且它编译得很好,但是当我尝试使用带或不带“call”的函数时,它抛出:

Error(36,24): PLS-00222: no function with name ‘x’ exists in this
scope

这是函数的样子:

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;
总结

以上是内存溢出为你收集整理的Oracle – 此范围内不存在名称为X的函数全部内容,希望文章能够帮你解决Oracle – 此范围内不存在名称为X的函数所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/1160795.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-01
下一篇 2022-06-01

发表评论

登录后才能评论

评论列表(0条)

保存