Oracle 8i Data Cartridge Developer's Guide Release 2 (8.1.6) Part Number A76937-01 |
|
SBTREE: An Example of Extensible Indexing, 4 of 8
The SBtree
indextype supports three operators. Each operator has a corresponding functional implementation. The functional implementations of the eq
, gt
and lt
operators are presented next.
The functional implementation for eq
is provided by a function (bt_eq
) that takes in two VARCHAR2
parameters and returns 1 if they are equal and 0 otherwise.
CREATE FUNCTION bt_eq(a VARCHAR2, b VARCHAR2) RETURN NUMBER AS BEGIN IF a = b then RETURN 1; ELSE RETURN 0; END IF; END;
The functional implementation for lt
is provided by a function (lt_eq
) that takes in two VARCHAR2
parameters and returns 1 if the first parameter is less than the second, 0 otherwise.
CREATE FUNCTION bt_lt(a VARCHAR2, b VARCHAR2) RETURN NUMBER AS BEGIN IF a < b then RETURN 1; ELSE RETURN 0; END IF; END;
The functional implementation for gt
is provided by a function (gt_eq
) that takes in two VARCHAR2
parameters and returns 1 if the first parameter is greater than the second, 0 otherwise.
CREATE FUNCTION bt_gt(a VARCHAR2, b VARCHAR2) RETURN NUMBER AS BEGIN IF a > b then RETURN 1; ELSE RETURN 0; END IF; END;
To create the operator, you need to specify the signature of the operator along with its return type and also its functional implementation.
CREATE OPERATOR eq BINDING (VARCHAR2, VARCHAR2) RETURN NUMBER USING bt_eq;
CREATE OPERATOR lt BINDING (VARCHAR2, VARCHAR2) RETURN NUMBER USING bt_lt;
CREATE OPERATOR gt BINDING (VARCHAR2, VARCHAR2) RETURN NUMBER USING bt_gt;
|
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|