4-7. Passing Parameters by Name

Problem

You have a procedure in your database that accepts a large number of parameters. When calling the procedure, you would rather not worry that the positioning of the parameters is correct.

Solution

Rather than trying to pass all the parameters to the procedure in the correct order, you can pass them by name. The code in this solution calls a procedure that accepts six parameters, and it passes the parameters by name rather than in order.

Procedure Declaration:
PROCEDURE process_emp_paycheck(EMP_ID IN NUMBER,    PAY_CODE IN NUMBER,    SICK_USED IN NUMBER,    VACATION_USED IN NUMBER,    FEDERAL_TAX IN NUMBER,    STATE_TAX IN NUMBER);
Procedure Execution:
EXEC process_emp_paycheck(EMP_ID=>10,    PAY_CODE=>10, ...

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.