You are on page 1of 7

ITC-327: Database Administration & Management

Name: MUZAMMIL AHMED


Enrollment no: 02-235202-040

Lab 11: Types Of Methods


Exercises

1. MEMBER METHODS

• Create an object type EMP_TYPE having: ATTRIBUTES v_ename varchar2(10) v_sal number
v_job varchar2(10) MEMBER METODS member procedure info(p_empno in number) member
procedure display

• Define the member methods in the object type body as follows: EMPNO must be passed as input
parameter in member procedure INFO. ENAME, SAL and JOB of the input EMPNO must be fetched
in the member attributes. Procedure DISPLAY will display the values of the member attributes.

• Create an instance of the object type in anonymous block and display the ENAME,SAL and JOB
of any employee number using member methods.
2. STATIC METHODS

• Create an object type EMP_TYPE having: ATTRIBUTES v_ename varchar2(10) v_sal number
v_job varchar2(10) STATIC METHOD static procedure info(p_empno in number,p_ename out
varchar2,p_sal out number,p_job out varchar2) MEMBER METOD member procedure display

• Define the methods in the object type body as follows: EMPNO must be passed as input
parameter in static procedure INFO. ENAME, SAL and JOB of the input EMPNO must be returned
from the procedure. Procedure DISPLAY will display the values of the member attributes.

• Create an instance of the object type in anonymous block and display the ENAME,SAL and JOB
of any employee number using defined methods.
3. CONSTRUCTORS

Create an object type EMP_TYPE having: ATTRIBUTES v_ename varchar2(10) v_sal number
v_job varchar2(10)

CONSTRUCTOR METHOD constructor function emp_type(p_empno in number) return self as result


MEMBER METOD member procedure display
4. MAP MEMBER FUNCTION
• Create an object type EMP_TYPE having: ATTRIBUTES v_empno number v_ename
varchar2(10) v_hiredate date CONSTRUCTOR METHOD constructor function
emp_type(p_empno in number) return self as result MAP MEMBER FUNCTION map member
function compare return date MEMBER METOD member procedure display_senior Define
the methods in the object type body as follows: EMPNO must be passed as input parameter in
constructor function EMP_TYPE. ENAME and HIREDATE of the input EMPNO must be
returned from the constructor as SELF. Map member function COMPARE returns the hiredate of
the instance. Procedure DISPLAY_SENIOR will display the ENAME and HIREDATE of the
employee.
• Create two employees instances of the object type EMP_TYPE in anonymous block and
initialized them using defined constructor. Now compare both the employees instances using
MAP member function and display the ENAME and HIREDATE of the senior most employee
using DISPLAY_SENIOR member procedure
5. ORDER MEMBER FUNCTION
• Create an object type EMP_TYPE having: ATTRIBUTES v_empno number v_ename
varchar2(10) v_hiredate date CONSTRUCTOR METHOD constructor function emp_type(p_empno
in number) return self as result ORDER MEMBER FUNCTION order member function compare(e
emp_type) return number MEMBER METOD member procedure display_senior

• Define the methods in the object type body as follows: EMPNO must be passed as input
parameter in constructor function EMP_TYPE. ENAME and HIREDATE of the input EMPNO must
be returned from the constructor as SELF. SELF and second instance will be passed as parameters in
order member function COMPARE. -1 will be returned if the hiredate of SELF instance is less than
the hiredate of the second instance else 1 will be returned. Procedure DISPLAY_SENIOR will display
the ENAME and HIREDATE of the employee.

• Create two employees instances of the object type EMP_TYPE in anonymous block and
initialized them using defined constructor. Now compare both the employees instances using ORDER
member function and display the ENAME and HIREDATE of the senior most employee using
DISPLAY_SENIOR member procedure.

You might also like