PL/SQL User's Guide and Reference

Contents Index Home Previous Next

Positional and Named Notation

When calling a subprogram, you can write the actual parameters using either positional or named notation. That is, you can indicate the association between an actual and formal parameter by position or name. For example, given the declarations

DECLARE
   acct INTEGER;
   amt  REAL;
   PROCEDURE credit (acctno INTEGER, amount REAL) IS 
   BEGIN ... END;

you can call the procedure credit in four logically equivalent ways:

BEGIN
   ...
   credit(acct, amt);                      -- positional notation
   credit(amount => amt, acctno => acct);  -- named notation
   credit(acctno => acct, amount => amt);  -- named notation
   credit(acct, amount => amt);            -- mixed notation
END;

Positional Notation

The first procedure call uses positional notation. The PL/SQL compiler associates the first actual parameter, acct, with the first formal parameter, acctno. And, the compiler associates the second actual parameter, amt, with the second formal parameter, amount.

Named Notation

The second procedure call uses named notation. The arrow (called an association operator) associates the formal parameter to the left of the arrow with the actual parameter to the right of the arrow.

The third procedure call also uses named notation and shows that you can list the parameter pairs in any order. Therefore, you need not know the order in which the formal parameters are listed.

Mixed Notation

The fourth procedure call shows that you can mix positional and named notation. In this case, the first parameter uses positional notation, and the second parameter uses named notation. Positional notation must precede named notation. The reverse is not allowed. For example, the following procedure call is illegal:

credit(acctno => acct, amt);  -- illegal


Contents Index Home Previous Next