A type with member function:


SQL> CREATE TYPE t_emp AS OBJECT (
  2      id INTEGER,
  3      name VARCHAR2(15),
  4      description VARCHAR2(22),
  5      sal NUMBER(5, 2),
  6      hiredate DATE,
  7      MEMBER FUNCTION get_hire_date RETURN DATE
  8  );
  9  /

Type created.

SQL>
SQL> CREATE TYPE BODY t_emp AS
  2     MEMBER FUNCTION get_hire_date RETURN DATE IS
  3        v_date DATE;
  4     BEGIN
  5        SELECT hiredate INTO v_date FROM dual;
  6        RETURN v_date;
  7     END;
  8  END;
  9  /

Type body created.

SQL>

CREATE PUBLIC SYNONYM t_pub_emp FOR t_emp;
Home »
Oracle »
PL/SQL » 

Object Types:
  1. Creating Object Types
  2. A type with member function:
  3. Using DESCRIBE to Get Information on Object Types
  4. Using Object Types in Database Tables
  5. Retrieve an individual column object from a table
  6. Call method from type
  7. UPDATE/DELETE row based on custom data type
  8. Object Tables
  9. VALUE() selects a row from an object table.
  10. UPDATE Object Table
  11. DELETE rows from Object Table
  12. Object table abased on nested types
  13. Object Identifiers and Object References
  14. REF type for an object reference
  15. Retrieve the actual objects stored in an object reference using the DEREF() function,
  16. Comparing Object Values
Related: