Operators
The sample DataBlade module
defines the following four operators that can be used on columns of
data type MyShape, MyBox, MyCircle, and MyPoint in the WHERE clause
of a query:
- Overlap
- Returns a Boolean value to indicate whether two shapes intersect or overlap.
- Equal
- Returns a Boolean value to indicate whether two shapes are the same or occupy the same space.
- Contains
- Returns a Boolean value to indicate whether the first shape contains the second shape.
- Within
- Returns a Boolean value to indicate whether the first shape is within or is contained by the second shape.
These operators, of course, are also the strategy functions defined by the operator class.
The following example uses the Overlap operator
to return all the boxes in the box_tab table that overlap a
box whose lower-left coordinate is (30,20) and upper-right
coordinate is (60,50):
SELECT * FROM box_tab
WHERE Overlap (boxes, 'box(30,20,60,50)' );
id 1
boxes box(10,10,40,40)
The following example uses the Contains operator
to return all the boxes in the box_tab table that contain a
box whose lower-left coordinate is (-5,-10) and upper-right
coordinate is (2,5):
SELECT * FROM box_tab
WHERE Contains (boxes, 'box(-5,-10,2,5)' );
id 2
boxes box(-10,-20,5,9)