我怎样才能解决这个“SQL语句被忽略”的问题?错误?

发布于 2024-09-07 02:38:33 字数 651 浏览 1 评论 0原文

我有以下无法编译的小函数:

function f_query_01  Return interval Day to second is 
  start_time timestamp(3);
  end_time timestamp(3);
  time_diff interval Day to second;  
  c_query_number number;

begin

  start_time := systimestamp; 
  select count(*) into c_query_number from wg;  <--This is the line that errors out
  end_time := systimestamp;
  time_diff := start_time - end_time;

  return time_diff;

end f_query_01;

编译器给出以下错误:

Error(29,3): PL/SQL: SQL Statement ignored
Error(29,44): PL/SQL: ORA-04044: procedure, function, package, or type is not allowed here

是什么导致了此错误以及如何修复它?

I have the following small function that does not compile:

function f_query_01  Return interval Day to second is 
  start_time timestamp(3);
  end_time timestamp(3);
  time_diff interval Day to second;  
  c_query_number number;

begin

  start_time := systimestamp; 
  select count(*) into c_query_number from wg;  <--This is the line that errors out
  end_time := systimestamp;
  time_diff := start_time - end_time;

  return time_diff;

end f_query_01;

The compiler gives me the following errors:

Error(29,3): PL/SQL: SQL Statement ignored
Error(29,44): PL/SQL: ORA-04044: procedure, function, package, or type is not allowed here

What is causing this error and how can I fix it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

东京女 2024-09-14 02:38:33

看起来表 wg 不存在。当更新为正确的表名称时,编译不会出现错误。来自表不存在的编译器的消息将是最有帮助的。

It appears the table wg does not exist. When updated to the correct table name the compile works without errors. A message from the compiler of table does not exist would be most helpful.

讽刺将军 2024-09-14 02:38:33
CREATE OR REPLACE FUNCTION f_query_01
   RETURN NUMBER
IS
BEGIN
   DECLARE
      c_query_number   NUMBER DEFAULT NULL;
      start_time       DATE DEFAULT NULL;
      end_time         DATE DEFAULT NULL;
      time_diff        NUMBER DEFAULT NULL;
   BEGIN
      SELECT CAST (SYSTIMESTAMP AS DATE) INTO start_time FROM DUAL;

      SELECT COUNT (*) INTO c_query_number FROM ws;

      SELECT CAST (SYSTIMESTAMP AS DATE) INTO end_time FROM DUAL;

      time_diff := start_time - end_time;

      RETURN time_diff;
   END;
END f_query_01;
CREATE OR REPLACE FUNCTION f_query_01
   RETURN NUMBER
IS
BEGIN
   DECLARE
      c_query_number   NUMBER DEFAULT NULL;
      start_time       DATE DEFAULT NULL;
      end_time         DATE DEFAULT NULL;
      time_diff        NUMBER DEFAULT NULL;
   BEGIN
      SELECT CAST (SYSTIMESTAMP AS DATE) INTO start_time FROM DUAL;

      SELECT COUNT (*) INTO c_query_number FROM ws;

      SELECT CAST (SYSTIMESTAMP AS DATE) INTO end_time FROM DUAL;

      time_diff := start_time - end_time;

      RETURN time_diff;
   END;
END f_query_01;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文