Type with member procedure : Object Method « Object Oriented Database « Oracle PL / SQL






Type with member procedure

    
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.

   
    
    
    
  








Related examples in the same category

1.Creating User-defined Functions for Column Objects
2.Use method from object in select command
3.Access member variable in member function in a type
4.Compare two type object instances
5.A sample object type with a MAP member function
6.A sample object type with an ORDER member function.
7.This script builds a sample object type with member variables and functions
8.This script demonstrates the static method.
9.This script demonstrates the order method.
10.Demonstrates the member method.