oracle 如何执行oracle存储过程?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1854427/
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 to execute an oracle stored procedure?
提问by FlintOff
I am using oracle 10g express edition. It has a nice ui for db developers. But i am facing some problems executing stored procedures.
我使用的是oracle 10g express 版。它为数据库开发人员提供了一个很好的用户界面。但是我在执行存储过程时遇到了一些问题。
Procedure:
程序:
create or replace procedure temp_proc is
begin
DBMS_OUTPUT.PUT_LINE('Test');
end
it is created successfully. But when i execute:
它已成功创建。但是当我执行时:
execute temp_proc;
execute temp_proc;
it shows ORA-00900: invalid SQL statement
它显示ORA-00900: invalid SQL statement
So help needed here
所以这里需要帮助
回答by Thorsten
Execute
is sql*plus syntax .. try wrapping your call in begin .. end like this:
Execute
是 sql*plus 语法 .. 尝试将您的呼叫包装在 begin .. end 中,如下所示:
begin
temp_proc;
end;
(Although Jeffrey says this doesn't work in APEX .. but you're trying to get this to run in SQLDeveloper .. try the 'Run' menu there.)
(虽然 Jeffrey 说这在 APEX 中不起作用 .. 但你试图让它在 SQLDeveloper 中运行 .. 尝试那里的“运行”菜单。)
回答by Jeffrey Kemp
Oracle 10g Express Edition ships with Oracle Application Express (Apex) built-in. You're running this in its SQL Commands window, which doesn't support SQL*Plus syntax.
Oracle 10g Express Edition 附带内置的 Oracle Application Express (Apex)。您正在其 SQL 命令窗口中运行它,该窗口不支持 SQL*Plus 语法。
That doesn't matter, because (as you have discovered) the BEGIN...END syntax does work in Apex.
这并不重要,因为(如您所见)BEGIN...END 语法在 Apex 中确实有效。
回答by Jim Gettman
Both 'is' and 'as' are valid syntax. Output is disabledby default. Try a procedure that also enables output...
'is' 和 'as' 都是有效的语法。默认情况下禁用输出。尝试一个也启用输出的过程......
create or replace procedure temp_proc is
begin
DBMS_OUTPUT.ENABLE(1000000);
DBMS_OUTPUT.PUT_LINE('Test');
end;
...and call it in a PLSQL block...
...并在 PLSQL 块中调用它...
begin
temp_proc;
end;
...as SQL is non-procedural.
...因为 SQL 是非程序性的。
回答by Doan Vu Phong
I use oracle 12 and it tell me that if you need to invoke the procedure then use callkeyword. In your case it should be:
我使用 oracle 12,它告诉我,如果您需要调用该过程,请使用call关键字。在你的情况下,它应该是:
begin
call temp_proc;
end;
回答by Mr_Hic-up
Have you tried to correct the syntax like this?:
您是否尝试过像这样更正语法?:
create or replace procedure temp_proc AS
begin
DBMS_OUTPUT.PUT_LINE('Test');
end;