Type with member procedure : type body « Object Oriented « Oracle PL/SQL Tutorial






SQL>
SQL> CREATE TABLE emp
  2     (id         VARCHAR2(10) NOT NULL,
  3      course     VARCHAR2(10),
  4      year       VARCHAR2(4),
  5      PRIMARY KEY (id));

Table created.

SQL> CREATE OR REPLACE TYPE empType AS OBJECT
  2     (id                     VARCHAR2(10),
  3      course                 VARCHAR2(20),
  4      year                   VARCHAR2(4),
  5      MEMBER PROCEDURE       Delete_emp )
  6  /

Type created.

SQL>
SQL> CREATE OR REPLACE TYPE BODY empType AS
  2     MEMBER PROCEDURE
  3     Delete_emp IS
  4     BEGIN
  5           DELETE FROM emp
  6           WHERE emp.id = self.id;
  7     END Delete_emp;
  8  END;
  9  /

Type body created.

SQL> drop table emp;

Table dropped.








32.4.type body
32.4.1.Create type body
32.4.2.Type with method
32.4.3.Static Method
32.4.4.Implement a function in type body
32.4.5.Create toString function for a type
32.4.6.Object table
32.4.7.Type with order function
32.4.8.Type with member procedure