CREATE TYPE person_typ AS OBJECT (
idno NUMBER,
first_name VARCHAR2(20),
last_name VARCHAR2(25),
email VARCHAR2(25),
phone VARCHAR2(20),
MAP MEMBER FUNCTION get_idno RETURN NUMBER
);
CREATE TYPE BODY person_typ AS
MAP MEMBER FUNCTION get_idno RETURN NUMBER IS
BEGIN
RETURN idno;
END;
END;
CREATE TABLE contacts (
contact person_typ,
contact_date DATE );
INSERT INTO contacts
VALUES
( person_typ (65, 'Verna', 'Mills', 'vmills@example.com', '1-650-555-0125'), '24 Jun 2003' );
然后,根据documentation
当需要调用方法get_idno()
时,应该这样做:
SELECT c.contact.get_idno() FROM contacts c;
为什么这里需要使用别名?也就是说,为什么不这样做:
SELECT contacts.contact.get_idno() FROM contacts;
答案 0 :(得分:0)
您可以将其与面向对象编程进行比较。
You need to create the instance of an object , before using any methods of it .
You can not directly call it by using contacts