Header Ads Widget

Responsive Advertisement

Module 04: Working with Packages

Working with Packages

01. What is Overloading Subprograms in PL/SQL?


a. Enables you to create two or more subprograms with the same name 

b. Requires that the subprogram’s formal parameters differ in number, order, or data type family

c. Enables you to build flexible ways for invoking subprograms with different data 

d. Provides a way to extend functionality without loss of existing code; that is, adding new parameters to existing subprograms 

e. Provides a way to overload local subprograms, package subprograms, and type methods, but not stand-alone subprograms

02. Write down the consideration of using overloading when.

Consider using overloading when: 

a. Processing rules for two or more subprograms are similar, but the type or number of parameters used varies.

b. Providing alternative ways for finding different data with varying search criteria. For example, you may want to find employees by their employee ID and also provide a way to find employees by their last name. The logic is intrinsically the same, but the parameters or search criteria differ. 

c. Extending functionality when you do not want to replace existing code.

03. Write down the restrictions using overloading.

You cannot overload: 

a. Two subprograms if their formal parameters differ only in data type and the different data types are in the same family (NUMBER and DECIMAL belong to the same family).

b. Two subprograms if their formal parameters differ only in subtype and the different subtypes are based on types in the same family (VARCHAR and STRING are PL/SQL subtypes of VARCHAR2).

c. Two functions that differ only in return type, even if the types are in different families.

Post a Comment