PL/SQL Developer 中执行过程的问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5203431/
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
Problem with execute procedure in PL/SQL Developer
提问by
I this is my first attempt to create procedure and execute it. First I create simple table. DB scheme of table is here:
这是我第一次尝试创建程序并执行它。首先我创建简单的表。表的数据库方案在这里:
Table name: Ziaci
表名:Ziaci
Columns:
列:
- ZiakId - primary key, number
- Surname, varchar2
- FirstName, varchar2
- TriedaId - forgein key, number
- ZiakId - 主键,数字
- 姓氏,varchar2
- 名字,varchar2
- TriedaId - 外键、号码
Store procedure only insert data in table, I created store procudure with this SQL cmd:
存储过程只在表中插入数据,我用这个 SQL cmd 创建了存储过程:
create procedure ziaci_proc(surname_in in varchar2,
firstname_in in varchar2, triedaid_in in number)
is
begin
insert into ziaci (surname, firstname,triedaid) values (surname_in,firstname_in,triedaid_in);
end;
And I try call this procudure as:
我试着把这个程序称为:
execute ziaci_proc('X','Y',1)
I get this error:
我收到此错误:
ORA-00900 invalid SQL statement
ORA-00900 无效的 SQL 语句
An in PL/SQL Developer IDE is with red color underlined execute word.
PL/SQL Developer IDE 中的一个带有红色下划线的执行字。
I test this procedure and it works good.
我测试了这个程序,效果很好。
I can only execute this procedure with this SQL command:
我只能使用此 SQL 命令执行此过程:
begin
ziaci_proc('A','B',2);
end;
What is bad, thank for help.
有什么不好的,谢谢帮助。
采纳答案by Luke Woodward
Calling stored procedures using execute
as above is specific to SQL*Plus. In fact, SQL*Plus converts execute some_proc()
into BEGIN some_proc(); END;
, You can see this for yourself by attempting to call a procedure that doesn't exist:
使用execute
上述方法调用存储过程是 SQL*Plus 特有的。事实上,SQL*Plus 转换execute some_proc()
为BEGIN some_proc(); END;
,您可以通过尝试调用一个不存在的过程来亲眼看到这一点:
SQL> execute some_proc() BEGIN some_proc(); END; * ERROR at line 1: ORA-06550: line 1, column 7: PLS-00201: identifier 'SOME_PROC' must be declared ORA-06550: line 1, column 7: PL/SQL: Statement ignored
回答by javanna
I think you're writing command in "SQL Window". You should use "Command Window" to succesfully execute this line:
我认为您是在“SQL 窗口”中编写命令。您应该使用“命令窗口”成功执行此行:
execute ziaci_proc('X','Y',1);