User Defined Functions (UDF)

Apollo Server allows you to create custom user-defined functions that extend the built-in Apollo functions provided by Apollo. Developers can use Delphi to create these powerful UDFs which are Win32 .DLL files that contain exported functions. UDFs are recognized by Apollo as native functions. UDFs can be used to define powerful Triggers and V-Script indexes.

For example, if you want to dynamically split a column called "FullName" into "FirstName" and "LastName" indexe keys, you could create 2 UDFs: ExtractFirstName( [fullname]) and ExtractLastName( [fullname] ) that will return the extracted text. ExtractFirstName would contain logic that returned the first part of the "FullName" column and ExtractLastName would have logic that returned the second part of the FullName data. The returned value would then be processed by the Apollo database engine as if it came from a native function.

Steps to create a UDF

  1. Create a UDF Win32 DLL using Delphi that contains some exported functions
  2. Create an Apollo7.UDF text file that tells Apollo engine where the UDF .DLL is, what funtcions are available and how to call them
  3. Copy the .UDF into the same directory as the SDE*.DLL

Apollo7.UDF is a text file that contains a list of all UDF functions with corresponding DLL names and functions. This Apollo7.UDF file must exist in the same directory as the SDE*.DLL engine. Apollo allows you to define an unlimited number UDFs. Each UDF supports up to 8 parameters. UDF parameters and the return value can be one of the following types:

  • CHARACTER
  • BOOLEAN
  • INT32
  • DOUBLE

The UDF file variablss are as follows:

  • DLLName - full path and name of the .DLL that contains the
  • UDF DLLFuncName - name of exported function in the .DLL
  • vFuncName - alias name of the DLLFuncName that is recognized by V-Script
  • ReturnType - return value type (one of the types listed above)
  • Param?Type - 1 of 8 param types (e.g. Param1Type) (one of the types listed above)