SQL> CREATE OR REPLACE TYPE book_obj AS OBJECT (
2 isbn CHAR (10),
3 title VARCHAR2 (100),
4 num_pages NUMBER,
5 ORDER MEMBER FUNCTION compare_book (p_isbn IN BOOK_OBJ)
6 RETURN NUMBER
7 );
8 /
Type created.
SQL>
SQL> CREATE OR REPLACE TYPE BODY book_obj
2 AS
3 ORDER MEMBER FUNCTION compare_book (p_isbn IN BOOK_OBJ)
4 RETURN NUMBER
5 IS
6 BEGIN
7 IF p_isbn.isbn < SELF.isbn
8 THEN
9 RETURN 1;
10 ELSIF p_isbn.isbn > SELF.isbn
11 THEN
12 RETURN -1;
13 ELSE
14 RETURN 0;
15 END IF;
16 END compare_book;
17 END;
18 /
Type body created.
SQL>