如何修复此“忽略 SQL 语句”错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3113211/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I fix this "SQL Statement ignored" error?
提问by twamn
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?
是什么导致了这个错误,我该如何解决?
回答by twamn
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.
表 wg 似乎不存在。当更新为正确的表名时,编译工作没有错误。来自表不存在的编译器的消息将是最有帮助的。
回答by UltraCommit
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;