--delete emp_object, or dept_object cannot be built again DROP TYPE Emp_object; --Define departmental classes CREATE OR REPLACE TYPE dept_object As Object ( Atri_deptno Number (2),--Department No. Atri_dname VARCHAR2 (14),--Department name Atri_loc VARCHAR2 (13),--Department position --Get object information Member FUNCTION ToString return VARCHAR2 ) not FINAL; / --Define the person class specification CREATE OR REPLACE TYPE person_object As Object ( Atri_pid number,--personnel ID Atri_name VARCHAR2 (10),--Name of person Atri_sex VARCHAR2 (10),--Gender of personnel Not instantiable member FUNCTION ToString return VARCHAR2--defining abstract methods --Implementing object sorting Not instantiable MAP member FUNCTION compare return number Not FINAL, not instantiable; --You must use the not Instantiable declaration class here / --Defines the EMP class specification, which is the person subclass CREATE OR REPLACE TYPE emp_object UNDER person_object ( Atri_job VARCHAR2 (9),--Employee position Atri_sal Number (7,2)--Employee pay Atri_comm number (7,2),--Employee Commission Atri_dept Dept_object--employee Department --This function name is the same as the parent class function name, so here is the override of the function Overriding member FUNCTION ToString return VARCHAR2, --Implementing object sorting overriding MAP member FUNCTION compare return number ) ; / --Define the Dept_object class body CREATE OR REPLACE TYPE body dept_object as Member FUNCTION ToString return VARCHAR2 as BEGIN Return ' Department No.: ' | | Self.atri_deptno | | ', Name: ' | | Self.atri_dname | | ', Location: ' | | Self.atri_loc; End; End; / --Define the Emp_object class body CREATE OR REPLACE TYPE body emp_object as Overriding member FUNCTION ToString return VARCHAR2 as BEGIN Return ' person number: ' | | Self.atri_pid | | ', Name: ' | | Self.atri_name | | ', Sex: ' | | Self.atri_sex | | ' Position: ' | | Self.atri_job | | ', Wages: ' | | Self.atri_sal | | ', Commission: ' | | Self.atri_comm; End; overriding MAP member FUNCTION compare return number as BEGIN return self.atri_sal + Self.atri_comm; End; End; / |