I am trying to create a main Oracle stored procedure, calling other Oracle stored procedures. I am getting a syntax error in Toad.
The environment is Windows Server 2012R2 and the Oracle edition is 12.1.0.
The main stored procedure is simple:
CREATE OR REPLACE PROCEDURE TESTDB.MAIN
(
ID IN NUMBER
)
IS
BEGIN
CALL PROCEDURE1(ID);
CALL PROCEDURE2(ID);
CALL PROCEDURE3(ID);
CALL PROCEDURE4(ID);
END;
I am getting a syntax error while compiling for each procedure:
PLS-00103: Encountered the symbol "PROCEDURE1" when expecting one of the following:
:= . ( @ % ; The symbol ":=" was substituted for "PROCEDURE1" to continue.
What is the correct syntax in order to call the procedures from one central procedure?
You have to remove CALL
, that can only be used
to execute a routine […] from within SQL
BEGIN
PROCEDURE1(ID);
PROCEDURE2(ID);
PROCEDURE3(ID);
PROCEDURE4(ID);
END;
For example:
SQL> create or replace procedure proc(n IN OUT number) is begin n := 10; end;
2 /
Procedure created.
SQL> var x number
SQL> call proc(:x);
Call completed.
SQL> print :x
X
----------
10
SQL> declare
2 y number;
3 begin
4 call proc(y);
5 end;
6 /
call proc(y);
*
ERROR at line 4:
ORA-06550: line 4, column 8:
PLS-00103: Encountered the symbol "PROC" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "PROC" to continue.
SQL>