Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To access the super methods, try either general invocation or generalized expression. For example, using a person supertype and student subtype:</p> <pre><code>CREATE OR REPLACE TYPE person_typ AS OBJECT ( idno number, name varchar2(30), phone varchar2(20), MAP MEMBER FUNCTION get_idno RETURN NUMBER, MEMBER FUNCTION show RETURN VARCHAR2) NOT FINAL; CREATE OR REPLACE TYPE BODY person_typ AS MAP MEMBER FUNCTION get_idno RETURN NUMBER IS BEGIN RETURN idno; END; MEMBER FUNCTION show RETURN VARCHAR2 IS BEGIN -- function that can be overriden by subtypes MEMBER FUNCTION show RETURN VARCHAR2 IS BEGIN RETURN 'Id: ' || TO_CHAR(idno) || ', Name: ' || name; END; END; CREATE TYPE student_typ UNDER person_typ ( dept_id NUMBER, major VARCHAR2(30), OVERRIDING MEMBER FUNCTION show RETURN VARCHAR2) NOT FINAL; CREATE TYPE BODY student_typ AS OVERRIDING MEMBER FUNCTION show RETURN VARCHAR2 IS BEGIN RETURN (self AS person_typ).show || ' -- Major: ' || major ; END; END; -- Using Generalized Invocation DECLARE myvar student_typ := student_typ(100, 'Sam', '6505556666', 100, 'Math'); name VARCHAR2(100); BEGIN name := (myvar AS person_typ).show; --Generalized invocation END; -- Using Generalized Expression DECLARE myvar2 student_typ := student_typ(101, 'Sam', '6505556666', 100, 'Math'); name2 VARCHAR2(100); BEGIN name2 := person_typ.show((myvar2 AS person_typ)); -- Generalized expression END; </code></pre> <p>EDIT:</p> <p>If you are on 10g, you'll need to organize the functions a bit different, but same functionality from the child to call the super method:</p> <pre><code>CREATE TYPE BODY person_typ AS MAP MEMBER FUNCTION get_idno RETURN NUMBER IS BEGIN RETURN idno; END; -- static function that can be called by subtypes STATIC FUNCTION show_super (person_obj in person_typ) RETURN VARCHAR2 IS BEGIN RETURN 'Id: ' || TO_CHAR(person_obj.idno) || ', Name: ' || person_obj.name; END; -- function that can be overriden by subtypes MEMBER FUNCTION show RETURN VARCHAR2 IS BEGIN RETURN person_typ.show_super ( SELF ); END; END; CREATE TYPE student_typ UNDER person_typ ( dept_id NUMBER, major VARCHAR2(30), OVERRIDING MEMBER FUNCTION show RETURN VARCHAR2) NOT FINAL; CREATE TYPE BODY student_typ AS OVERRIDING MEMBER FUNCTION show RETURN VARCHAR2 IS BEGIN RETURN person_typ.show_super ( SELF ) || ' -- Major: ' || major ; END; END; </code></pre> <p>Now you'd call show_super() from student for the person method, or just show() for the student method.</p> <p>From the docs, hope that helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload