PL/SQL Developer 中执行过程的问题

2021-12-24 00:00:00 sql oracle plsql procedure ora-00900

这是我第一次尝试创建过程并执行它.首先我创建简单的表.表的数据库方案在这里:

表名:Ziaci

列:

  • ZiakId - 主键、数字
  • 姓氏,varchar2
  • 名字,varchar2
  • TriedaId - 伪造密钥、号码

存储过程只在表中插入数据,我用这个 SQL cmd 创建了存储过程:

create procedure ziaci_proc(surname_in in varchar2,varchar2 中的 firstname_in,数字中的 tryaid_in)是开始插入 ziaci (surname, firstname,triedaid) 值 (surname_in,firstname_in,triedaid_in);结尾;

我试着把这个程序称为:

执行ziaci_proc('X','Y',1)

我收到此错误:

ORA-00900 无效的 SQL 语句

PL/SQL Developer IDE 中的一个带有红色下划线的执行字.

我测试了这个程序,效果很好.

我只能用这个 SQL 命令来执行这个过程:

开始ziaci_proc('A','B',2);结尾;

有什么不好的,谢谢帮助.

解决方案

使用上述 execute 调用存储过程是特定于 SQL*Plus 的.实际上,SQL*Plus 将 execute some_proc() 转换为 BEGIN some_proc();END;,你可以通过尝试调用一个不存在的过程来亲眼看到这一点:

<前>SQL> 执行 some_proc()开始 some_proc();结尾;*第 1 行的错误:ORA-06550:第 1 行,第 7 列:PLS-00201:必须声明标识符SOME_PROC"ORA-06550:第 1 行,第 7 列:PL/SQL:语句被忽略

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

Columns:

  • ZiakId - primary key, number
  • Surname, varchar2
  • FirstName, varchar2
  • TriedaId - forgein key, number

Store procedure only insert data in table, I created store procudure with this 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

An in PL/SQL Developer IDE is with red color underlined execute word.

I test this procedure and it works good.

I can only execute this procedure with this SQL command:

begin
ziaci_proc('A','B',2);
end;

What is bad, thank for help.

解决方案

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:

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

相关文章