葉片型別
型別宣告:
CREATE OR REPLACE TYPE leaf_type UNDER mid_type
(
leaf_attr VARCHAR2(1000),
CONSTRUCTOR FUNCTION leaf_type
(
i_base_id INTEGER,
i_base_attr VARCHAR2,
i_mid_attr DATE,
i_leaf_attr VARCHAR2
) RETURN SELF AS RESULT,
MEMBER FUNCTION get_leaf_attr RETURN VARCHAR2,
MEMBER PROCEDURE set_leaf_attr(i_leaf_attr VARCHAR2),
OVERRIDING MEMBER FUNCTION to_string RETURN VARCHAR2
) INSTANTIABLE FINAL
型別正文:
CREATE OR REPLACE TYPE BODY leaf_type AS
CONSTRUCTOR FUNCTION leaf_type
(
i_base_id INTEGER,
i_base_attr VARCHAR2,
i_mid_attr DATE,
i_leaf_attr VARCHAR2
) RETURN SELF AS RESULT
IS
BEGIN
self.base_id := i_base_id;
self.base_attr := i_base_attr;
self.mid_attr := i_mid_attr;
self.leaf_attr := i_leaf_attr;
RETURN;
END leaf_type;
MEMBER FUNCTION get_leaf_attr RETURN VARCHAR2 IS
BEGIN
RETURN self.leaf_attr;
END get_leaf_attr;
MEMBER PROCEDURE set_leaf_attr(i_leaf_attr VARCHAR2) IS
BEGIN
self.leaf_attr := i_leaf_attr;
END set_leaf_attr;
OVERRIDING MEMBER FUNCTION to_string RETURN VARCHAR2 IS
BEGIN
RETURN (SELF AS mid_type).to_string || '; LEAF_ATTR [' || self.leaf_attr || ']';
END to_string;
END;