我用的是oracle 10g express版。它为数据库开发人员提供了一个不错的用户界面。但是我在执行存储过程时遇到了一些问题。
程序:
create or replace procedure temp_proc is
begin
DBMS_OUTPUT.PUT_LINE('Test');
end
它创建成功。但是当我执行时:
execute temp_proc;
它显示ORA-00900: 无效的 SQL 语句
所以这里需要帮助
Execute
是 sql*plus 语法 .. 尝试将您的调用包装在 begin .. end 中,如下所示:
begin
temp_proc;
end;
(虽然 Jeffrey 说这在 APEX 中不起作用 .. 但您正试图让它在 SQLDeveloper 中运行 .. 尝试那里的“运行”菜单。)
Oracle 10g Express Edition 附带内置的 Oracle Application Express (Apex)。您在其 SQL 命令窗口中运行它,该窗口不支持 SQL*Plus 语法。
没关系,因为(正如您所发现的)BEGIN...END 语法在 Apex 中确实有效。
'is' 和 'as' 都是有效的语法。默认情况下禁用输出。尝试一个也启用输出的过程...
create or replace procedure temp_proc is
begin
DBMS_OUTPUT.ENABLE(1000000);
DBMS_OUTPUT.PUT_LINE('Test');
end;
...并在 PLSQL 块中调用它...
begin
temp_proc;
end;
...因为 SQL 是非过程的。
我使用 oracle 12,它告诉我如果您需要调用该过程,请使用call关键字。在您的情况下,它应该是:
begin
call temp_proc;
end;
您是否尝试过纠正这样的语法?:
create or replace procedure temp_proc AS
begin
DBMS_OUTPUT.PUT_LINE('Test');
end;
您可以在命令行窗口中简单地执行以下操作:
Connected to Oracle Database 19c Enterprise Edition Release 19.0.0.0.0
Connected as XXX@YYY
SQL> call temp_proc();
或者:
SQL> execute temp_proc();