Oracle 8i Data Cartridge Developer's Guide Release 2 (8.1.6) Part Number A76937-01 |
|
Defining Object Types , 5 of 5
SQL performs comparison operations on objects. Comparisons can be explicit, using the comparison operators (=, <, >, <>, <=, >=, !=) and the BETWEEN
and IN
predicates. Comparisons can be implicit, as in the GROUP
BY
, ORDER
BY
, DISTINCT
, and UNIQUE
clauses.
Comparison of objects makes use of special member functions of the object type: map methods and order methods. To perform object comparison, you must implement either a map method or order method in the CREATE
TYPE
and CREATE
TYPE
BODY
statements.
For example, the type body for the DataStream type, implements the map member function for DataStream comparison as:
MAP MEMBER FUNCTION DataStreamToInt return integer is c integer := id; begin return c; end;
This definition of the map member function relies on the presence of the id attribute of the DataStream type to map instances to integers. Whenever a comparison operation is required between objects of type DataStream, the map function DataStreamToInt () is called implicitly by the system.
The object type rational_type does not have a simple id attribute like that for DataStream. For rational_type, the map member function is slightly more complicated. Because a map function can return any of the built-in types; rational_type can return a value or type REAL
:
MAP MEMBER FUNCTION RationalToReal RETURN REAL IS BEGIN RETURN numerator/denominator; END; ...
If you have not defined a map or order function for an object type, only equality comparisons are allowed on objects of that type. Oracle SQL performs the comparison by doing a field-by-field comparison of the attributes of that type.
|
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|