MarthinusSwart.com

PL/SQL Named Parameters.

PL/SQL has a nice feature where parameters aren't just passed by position like in many other programming languages. In PL/SQL you can specify which value will be assigned to which parameter in any order. If we have the following procedure:

PROCEDURE UpdateProgress (
    aProgress_Id IN mySchema.myTable.SEQ%TYPE,
    aDescription IN mySchema.myTable.DESCRIPTION%TYPE DEFAULT NULL,
    aCount       IN mySchema.myTable.ITEM_COUNT%TYPE,
    aErrorCount  IN mySchema.myTable.ERROR_COUNT%TYPE DEFAULT DEFAULT_ERROR_COUNT,
    aStatus      OUT mySchema.myTable.STATUS%TYPE);

we can invoke this procedure as follows:

/* The OUT variable that will store the progress status */
my_progress_status mySchema.myTable.STATUS%TYPE;

/* The IN variable that will have the progress id */
my_progress_id mySchema.myTable.SEQ%TYPE;

my_progress_id = 1;
/* Now invoke the procedure with the named parameters */
mySchema.myPackage.UpdateProgress(
    aProgress_Id => my_progress_id,
    aDescription => 'Importing...',
    aCount       => 0,
    aErrorCount  => 0,
    aStatus      => my_progress_status);