4-5. Executing a Stored Procedure

Problem

You want to execute a stored procedure from SQL*Plus.

Solution

Open SQL*Plus, and connect to the database schema that contains the procedure you are interested in executing. Execute the procedure by issuing the following command:

EXEC procedure_name([param1, param2,...]);

For instance, to execute the procedure that was created in Recipe 4-3, you would issue the following command:

EXEC increase_wage(198, .03, 5000);

This would invoke the INCREASE_WAGE procedure, passing three parameters: EMPLOYEE_ID, a percentage of increase, and an upper salary bound.

You can also execute a stored procedure by creating a simple anonymous block that contains the procedure call, as depicted in the following code:

Get Oracle and PL/SQL Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.