Routine overloading refers to the ability to assign
one name to multiple routines and specify different types of arguments
on which the routines can operate. In a type hierarchy, a subtype
automatically inherits the routines that are defined on its supertype.
However you can define a new routine on a subtype to override the
inherited routine with the same name. For example, suppose you create
a getinfo() routine on type person_t that returns the
last name and birthdate of an instance of type person_t. You
can register another getinfo() routine on type employee_t that
returns the last name and salary from an instance of employee_t.
In this way, you can overload a routine, so that you have a customized
routine for every type in the type hierarchy, as the following figure
shows.
When you overload a routine so that routines are defined with the
same name but different arguments for different types in the type
hierarchy, the argument that you specify determines which routine
executes. For example, if you call getinfo() with an argument
of type employee_t, a getinfo() routine defined on type employee_t overrides
the inherited routine of the same name. Similarly, if you define another getinfo() on
type sales_rep_t, a call to getinfo() with an argument
of type sales_rep_t overrides the routine that sales_rep_t inherits
from employee_t.
For information about how to create and register user-defined routines
(UDRs), see HCL OneDB™ User-Defined
Routines and Data Types Developer's Guide.
Have feedback?
Google Analytics is used to store comments and ratings. To provide a comment or rating for a topic, click Accept All Cookies or Allow All in Cookie Preferences in the footer of this page.