Example of creating a strategy function

This example describes the SQL statement that registers the Contains strategy function with the database server. The sample C code to create the function is provided in Shapes3 sample DataBlade module; the example is based on the objects of the sample DataBlade® module.

The SQL statements to register the Overlap, Equal, and Within strategy functions with the database server are similar to the SQL statement to register the Contains function.
Tip: The Informix® DataBlade® Developers Kit (DBDK) automatically generates the SQL statement to create the function.
The following SQL statement shows how to register the Contains strategy function with the database server:
CREATE FUNCTION Contains (MyShape, MyShape)
RETURNS BOOLEAN
WITH
(
    COMMUTATOR = Within,
    NOT VARIANT
)
EXTERNAL NAME "$INFORMIXDIR/extend/shapes.3.0/shapes.bld (MyShapeContains)"
LANGUAGE C;

The two parameters of the function are both of data type MyShape. The C function MyShapeContains, found in the shared object file $INFORMIXDIR/extend/Shapes.3.6/Shapes.bld, contains the actual C code that calculates whether the first object contains the second object. The statement specifies that the commutator of the Contains function is the Within function.

For the sample C code of the MyShapeContains function, see Contains strategy function. C code uses the DataBlade® API to interact with the database server. Sample C code to implement the Overlap, Equal, and Within functions is also provided in that topic.

For more information about the DataBlade® API, refer to the HCL® Informix® DataBlade® API Programmer's Guide.

For more information and examples about how to create user-defined functions, refer to HCL® Informix® User-Defined Routines and Data Types Developer's Guide.