Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Oracle ORA-06575:包或函数F处于无效状态_Oracle_Plsql - Fatal编程技术网

Oracle ORA-06575:包或函数F处于无效状态

Oracle ORA-06575:包或函数F处于无效状态,oracle,plsql,Oracle,Plsql,当我执行函数时,请给出以下错误: CREATE or replace FUNCTION f return integer AS; BEGIN return (select count(*) from exemplo); END ; select f() from dual; 运行alter会话集nls_language='English'以获取英文错误消息 函数必须如下所示: ORA-06575: Package or function F is in an invalid sta

当我执行函数时,请给出以下错误:

CREATE or replace FUNCTION  f
return integer
AS;
BEGIN 
  return (select count(*) from exemplo); 
END ;

select f() from dual;

运行
alter会话集nls_language='English'以获取英文错误消息

函数必须如下所示:

ORA-06575: Package or function F is in an invalid state

编译函数时,客户端会说:

CREATE or replace FUNCTION  f return integer AS
   ret INTEGER;
BEGIN 
   select count(*) INTO ret from exemplo; 
   return ret;
END;
LINE/COL ERROR
-------- -----------------------------------------------------------------
5/11     PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
         ( - + case mod new not null <an identifier>
         <a double-quoted delimited-identifier> <a bind variable>
         continue avg count current exists max min prior sql stddev
         sum variance execute forall merge time timestamp interval
         date <a string literal with character set specification>
         <a number> <a single-quoted SQL string> pipe
         <an alternatively-quoted string literal with character set specification>
         <an alternat
5/39     PLS-00103: Encountered the symbol ")" when expecting one of the following:
         . , @ ; for <an identifier>
         <a double-quoted delimited-identifier> group having intersect
         minus order partition start subpartition union where connect
         sample

如果您使用的是SQL*Plus或SQL Developer(可能还有其他客户端,但它们可能有自己的等效客户端),那么您可以执行
显示错误
以查看错误:

Function F compiled

Errors: check compiler log
不能直接返回查询结果。您需要选择一个局部变量,然后返回;比如:

CREATE or replace FUNCTION  f return integer AS
   ret INTEGER;
BEGIN 
   select count(*) INTO ret from exemplo; 
   return ret;
END;
LINE/COL ERROR
-------- -----------------------------------------------------------------
5/11     PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
         ( - + case mod new not null <an identifier>
         <a double-quoted delimited-identifier> <a bind variable>
         continue avg count current exists max min prior sql stddev
         sum variance execute forall merge time timestamp interval
         date <a string literal with character set specification>
         <a number> <a single-quoted SQL string> pipe
         <an alternatively-quoted string literal with character set specification>
         <an alternat
5/39     PLS-00103: Encountered the symbol ")" when expecting one of the following:
         . , @ ; for <an identifier>
         <a double-quoted delimited-identifier> group having intersect
         minus order partition start subpartition union where connect
         sample

为什么在
后面有一个分号作为
?编译函数后,它会告诉您有错误;使用
show errors
或查询
user\u errors
视图查看实际错误。无论是否存在错误,它们都不起作用
CREATE or replace FUNCTION  f
return integer
AS
  l_count pls_integer;
BEGIN 
  select count(*) into l_count from exemplo;
  return l_count; 
END ;
/