Writing User-Defined Functions

QDB allows you to write your own functions for manipulating data. The QDB library includes several data structures and functions useful for defining custom functionality, while the SQLite API provides methods your custom code can call to access arguments or set results.

There are two types of user-defined functions you can write for QDB to use: functions that transform some data (called scalar or aggregate functions), and functions that order data (called collation functions). The first type is invoked using the SELECT SQL statement, while the second by using the COLLATE clause. An example of a built-in scalar function is ABS(), while BINARY() is an example of a built-in collation function (see "Database configuration objects").

To define functions that QDB can use, you need to compile them into a DLL. You then tell QDB to load the DLL by setting the Collation and Function options in the database configuration object for each required function.