Method Example II (Cont.)


Use object constructs such as point_t( ) in a VALUES form of INSERT statement to insert rectangles (or points) built up out of constants.
SQL> create table  points  of  point_t ( 
  2    primary key (x, y) ); 

Table created.

SQL> create table  rects  of  rectangle_t ( 
  2    primary key (pt1.x, pt1.y, pt2.x, pt2.y) ); 

Table created.

SQL> insert into  rects  values (point_t(1, 2), point_t(3, 4)); 

1 row created.

SQL> insert into  rects  values (point_t(1, 1), point_t(6, 6)); 

1 row created.

SQL> insert into  points  values (2, 3); 

1 row created.

SQL> insert into  points  values (1, 4); 

1 row created.

SQL> insert into  points  values (4, 4); 

1 row created.


SQL> select  value(x), x.area( )  from  rects x; 

VALUE(X)(PT1(X, Y), PT2(X, Y))                   X.AREA( )
------------------------------------------   -------------
RECTANGLE_T(POINT_T(1, 2), POINT_T(3, 4))           4
RECTANGLE_T(POINT_T(1, 1), POINT_T(6, 6))          25




      “Knowledge speaks, but wisdom listens”    
      ― Jimi Hendrix