InterBase has several built in functions that developers can use to create and optimize SQL queries. In some situations though, you may find yourself needing to expand queries or work with more complex queries that include string, date and statistical functions. InterBase’s way to resolve this problem is by supporting libraries or user defined functions or UDFs. UDFs are programs for performing custom functions that are extensions of the server and execute as part of the server process. You can access UDFs through isql or a host-language program. You can also access UDFs in stored procedures and trigger bodies. UDFs can be used in a database application anywhere that a built-in SQL function can be used.
How to add UDFs to InterBase
There are several UDF libraries available on the internet for InterBase, but one with several functions that you can look into is FreeADHocUDF.
InterBase has two UDF files in the installation, one called udflib.dll (Employee db example shown in video) and the ib_udf.
You can also create your own UDF in this simple three-step process:
- Write the function in any programming language that can create a shared library. Functions written in Java are not supported.
- Compile the function and link it to a dynamically linked or shared library.
- Use DECLARE EXTERNAL FUNCTION to declare each UDF to each database in which you need to use it.
For more information on creating your own UDFs, check out the docwiki.