Search code examples
sqloracle-databaseplsqlprocedureora-00900

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.


Solution

  • 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