Working With Object Types
DROP TYPE address_typ;
CREATE TYPE address_typ AS OBJECT
(street VARCHAR2(30),
city VARCHAR2(20),
state CHAR(2),
postal_code VARCHAR2(6)
);
/
DROP TYPE employee_typ;
CREATE TYPE employee_typ AS OBJECT
(employee_id NUMBER(6),
first_name VARCHAR2(20),
last_name VARCHAR2(25),
email VARCHAR2(25),
phone_number VARCHAR2(20),
hire_date DATE,
job_id VARCHAR2(10),
salary NUMBER(8,2),
commission_pct NUMBER(2,2),
manager_id NUMBER(6),
department_id NUMBER(4),
address ADDRESS_TYP,
MAP MEMBER FUNCTION get_idno RETURN NUMBER,
MEMBER PROCEDURE display_address(SELF IN OUT NOCOPY EMPLOYEE_TYP)
);
/
CREATE TYPE BODY employee_typ AS
MAP MEMBER FUNCTION Get_idno
RETURN NUMBER
IS
BEGIN
RETURN employee_id;
END;
MEMBER PROCEDURE Display_address
(SELF IN OUT NOCOPY EMPLOYEE_TYP)
IS
BEGIN
dbms_output.Put_line(first_name
||' '
||last_name);
dbms_output.Put_line(address.street);
dbms_output.Put_line(address.city
||', '
||address.state
||' '
||address.postal_code);
END;
END;
/
CREATE TABLE employee_tab OF
employee_typ
;
OUTPUT: ALL Feedback return without any Errors.
0 comments:
Post a Comment