如何执行oracle存储过程?
我使用的是oracle 10g Express版。它为数据库开发人员提供了一个很好的用户界面。但我在执行存储过程时遇到一些问题。
过程:
create or replace procedure temp_proc is
begin
DBMS_OUTPUT.PUT_LINE('Test');
end
创建成功。但是当我执行:
execute temp_proc;
时,它显示ORA-00900:无效的SQL语句
所以这里需要帮助
I am using oracle 10g express edition. It has a nice ui for db developers. But i am facing some problems executing stored procedures.
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;
it shows ORA-00900: invalid SQL statement
So help needed here
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
Execute
是 sql*plus 语法.. 尝试将您的调用包装在 begin .. end 中,如下所示:(虽然 Jeffrey 说这在 APEX 中不起作用 .. 但您正在尝试让它运行在 SQLDeveloper 中..尝试那里的“运行”菜单。)
Execute
is sql*plus syntax .. try wrapping your call in begin .. end like this:(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.)
“is”和“as”都是有效的语法。默认情况下,输出禁用。尝试一个也支持输出的过程...
...并在 PLSQL 块中调用它...
...因为 SQL 是非过程的。
Both 'is' and 'as' are valid syntax. Output is disabled by default. Try a procedure that also enables output...
...and call it in a PLSQL block...
...as SQL is non-procedural.
Oracle 10g Express Edition 附带内置的 Oracle Application Express (Apex)。您在其 SQL 命令窗口中运行它,该窗口不支持 SQL*Plus 语法。
这并不重要,因为(正如您所发现的)BEGIN...END 语法在 Apex 中确实有效。
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.
That doesn't matter, because (as you have discovered) the BEGIN...END syntax does work in Apex.
在使用 12c 的 Oracle SQL Developer (GUI) 中,也不要忘记启用 DMBS Output 窗口(单击 View => Dbms Output >,然后单击“+”符号,并选择您的连接),默认情况下该窗口未启用。
以下语法将输出到该窗口:
In Oracle SQL Developer (GUI), using 12c, also don't forget to enable the DMBS Output window (click View => Dbms Output, then click "+" sign, and select your connection), by default the window is not enabled.
The following syntax will then output to this window:
我使用 oracle 12,它告诉我,如果您需要调用该过程,请使用 call 关键字。
在你的情况下应该是:
I use oracle 12 and it tell me that if you need to invoke the procedure then use call keyword.
In your case it should be:
您可以在命令行窗口上简单地执行以下操作:
或者:
You can do simply the following on the Command Window:
Or:
您是否尝试过像这样纠正语法?:
Have you tried to correct the syntax like this?: