Register a routine written in C

To register a C routine, write the body of the routine, compile it, and create a shared-object file, and then use the CREATE FUNCTION or CREATE PROCEDURE statement to register the function. The RETURNING clause of CREATE FUNCTION specifies the return data type of the function.

For example, the following CREATE FUNCTION statement registers a C function called equal() that takes two arguments, arg1 and arg2, of data type udtype1 and returns a single value of the data type BOOLEAN:
CREATE FUNCTION equal (arg1 udtype1, arg2 udtype1)
RETURNING BOOLEAN
EXTERNAL NAME '/usr/lib/udtype1/lib/libbtype1.so(udtype1_equal)'
LANGUAGE C
END FUNCTION;
Tip: In the preceding example, the END FUNCTION keywords are optional. C user-defined-routines can use either RETURNS or RETURNING.

For more information, see the CREATE FUNCTION and CREATE PROCEDURE statements in the HCL OneDB™ Guide to SQL: Syntax. For information about how to create a shared-object file, refer to the HCL OneDB DataBlade® API Programmer's Guide.