Those who are familiar with Object Oriented Programming (OOP) can easily understand the concept of overloading. Briefly, having the same name for different sub-programs with different parameters can be called overloading sub-programs. The following example gives you an illustration: create or replace package SamplePkg as create or replace package body SamplePkg as procedure dispEmp(p_deptno dept.deptno%type) as end SamplePkg; Within the above package, we declared two sub-programs as having the same name. But you should observe that the first sub-program doesn’t have any parameters, whereas the second sub-program does. If you execute with the following statement: Execute SamplePkg.dispEmp; It would automatically call the first sub-program (because you didn’t provide any parameters). If you execute with the following statement: Execute SamplePkg.dispEmp(10); It would automatically choose the second sub-program (because we provided a parameter). So, the selection of the respective sub-program will be automatically chosen by PL/SQL runtime based on the parameters we send. In that way, we can write as many sub-programs as possible with the same name, but with some differences in parameters.
blog comments powered by Disqus |