Problem with execute procedure in PL/SQL Developer

大憨熊 提交于 2019-12-18 07:38:04

问题


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.


回答1:


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



回答2:


I think you're writing command in "SQL Window". You should use "Command Window" to succesfully execute this line:

execute ziaci_proc('X','Y',1);


来源:https://stackoverflow.com/questions/5203431/problem-with-execute-procedure-in-pl-sql-developer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!