PROCEDURE statement creates or replaces a standalone procedure or a call specification.
A standalone procedure is a procedure (a subprogram that performs a specific action) that is stored in the database.
A standalone procedure that you create with the
PROCEDURE statement differs from a procedure that you declare and define in a PL/SQL block or package. For information about the latter, see "Procedure Declaration and Definition".
A call specification declares a Java method or a third-generation language (3GL) subprogram so that it can be called from PL/SQL. You can also use the SQL
CALL statement to invoke such a method or subprogram. The call specification tells the database which Java method, or which named procedure in which shared library, to invoke when an invocation is made. It also tells the database what type conversions to make for the arguments and return value.
To create or replace a standalone procedure in your schema, you must have the
PROCEDURE system privilege. To create or replace a standalone procedure in another user's schema, you must have the
PROCEDURE system privilege.
To invoke a call specification, you may need additional privileges, for example, the
EXECUTE object privilege on the C library for a C call specification.
To embed a
PROCEDURE statement inside an Oracle precompiler program, you must terminate the statement with the keyword
END-EXEC followed by the embedded SQL statement terminator for the specific language.
Re-creates the procedure if it exists, and recompiles it.
Users who were granted privileges on the procedure before it was redefined can still access the procedure without being regranted the privileges.
If any function-based indexes depend on the procedure, then the database marks the indexes
[ EDITIONABLE | NONEDITIONABLE ]
Specifies whether the procedure is an editioned or noneditioned object if editioning is enabled for the schema object type
EDITIONABLE. For information about editioned and noneditioned objects, see Oracle Database Development Guide.
Name of the schema containing the procedure. Default: your schema.
Name of the procedure to be created.
If you plan to invoke a stored subprogram using a stub generated by SQL*Module, then the stored subprogram name must also be a legal identifier in the invoking host 3GL language, such as Ada or C.
AUTHID property of the procedure. For information about the
AUTHID property, see "Invoker's Rights and Definer's Rights (AUTHID Property)".
Has the same behavior for a procedure as it does for a function. See the
The required executable part of the procedure and, optionally, the exception-handling part of the procedure.
The optional declarative part of the procedure. Declarations are local to the procedure, can be referenced in
body, and cease to exist when the procedure completes execution.
Creating a Procedure: Example
This statement creates the procedure
remove_emp in the schema
CREATE PROCEDURE remove_emp (employee_id NUMBER) AS tot_emps NUMBER; BEGIN DELETE FROM employees WHERE employees.employee_id = remove_emp.employee_id; tot_emps := tot_emps - 1; END; /
remove_emp procedure removes a specified employee. When you invoke the procedure, you must specify the
employee_id of the employee to be removed.
The procedure uses a
DELETE statement to remove from the
employees table the row of
"create_package_body.htm#GUID-68526FF2-96A1-4F14-A10B-4DD3E1CD80BE__I2098638" to see how to incorporate this procedure into a package
In this example, external procedure
c_find_root expects a pointer as a parameter. Procedure
find_root passes the parameter by reference using the
CREATE PROCEDURE find_root ( x IN REAL ) IS LANGUAGE C NAME c_find_root LIBRARY c_utils PARAMETERS ( x BY REFERENCE );
In this chapter:
In other chapters: