Improved Overloading on 10g

This entry is part 13 of 13 in the series New Pl/Sql features 10g

Originally overloading wasn’t possible for formal parameters that only differed in subtype. (for instance INTEGER is a subtype of NUMBER defined in DBMS_STANDARD)
Starting 10.1 Oracle introduced new overloading possibilities for numeric types. Overloaded modules can now only differ numeric subtype. This might speed up modules with heavy math as the calculus on BINARY datatypes might be faster that on a NUMBER datatype.

When overloading Numeric types follow these 2 simple steps

  1. Overload for every numeric type you expect to use
  2. Make the datatype of your actual parameters unambiguous by using conversion functions (TO_NUMBER(), TO_BINARY_FLOAT(), etc..) or use of explicit literals like (5.0d, 5.0f)

PL/SQL will try to match your actual parameters to one of the overloaded modules in specific order.

  1. match PLS_INTEGER or BINARY_INTEGER.
  2. match NUMBER
  3. match BINARY_FLOAT or BINARY_DOUBLE

The overloaded module that matches your actual parameters will be executed.

Series Navigation<< Compile-time warnings

Posted in Pl/Sql Tagged with: , ,

Leave a Reply