Procedures for overloading
You can create stored procedures that have the same procedure name, but which have different argument signatures and return types. This process is called overloading the procedure definition.
For example, assume that you have a procedure called customer_name()
that
can take two or three input strings, which represent the first, middle
(if specified), and surname of a customer.
TEST.TESTSCH(USR)=> CREATE PROCEDURE customer_name(VARCHAR(30), VARCHAR(30))
...
TEST.TESTSCH(USR)=> CREATE PROCEDURE customer_name(VARCHAR(30), VARCHAR(30),
VARCHAR(30))
...
If a user calls customer_name
with two input strings,
the system uses the first (two argument) procedure. If the user specifies
three input strings, the procedure uses the second procedure that
accepts three input strings.
You can use overloading to support different combinations of input values and return types. However, overloading and uniquely named but similar procedures have a maintenance overhead; if you need to update or redesign the body of the procedure, update each procedure definition with the changes that you want to make.