Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the syntax to define an Oracle procedure within an another stored procedure?

After many Google and SO searches, I cannot find a definitive answer to this simple question:

How can I define a procedure inside of another procedure to use?

I know that there are nested blocks and nested procedures, but I haven't seen the exact syntax for what I want. i.e.

create or replace
PROCEDURE TOP_PROCEDURE
(...)
IS
-- nested procedure here?
BEGIN
  NULL;
END;
like image 571
daveslab Avatar asked Dec 18 '09 16:12

daveslab


1 Answers

create or replace
PROCEDURE TOP_PROCEDURE
(...)
IS
   variable NUMBER;
   PROCEDURE nested_procedure (...)
   IS
   BEGIN
     NULL;
   END;
   PROCEDURE another_nested_procedure (...)
   IS
   BEGIN
     NULL;
   END;
BEGIN
  NULL;
END;

Local procedures must be declared after anything else (e.g. variables).

like image 105
Tony Andrews Avatar answered Nov 16 '22 00:11

Tony Andrews