Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

oracle - Problem with execute procedure in PL/SQL Developer

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...