A user-defined routine (UDR) is a routine that you can invoke within an SQL statement or another UDR. UDRs are building blocks for the development of DataBlade modules. Possible uses for a UDR follow:
For a more complete list, see Uses of a C UDR.
When you write a UDR in an external language (a language other than SPL), the UDR is called an external routine. An external routine that is written in the C language is called a C UDR. A C UDR uses the server-side implementation of the DataBlade API to communicate with the database server.
This section provides the following information about C UDRs. For general information about UDRs, see the IBM Informix: User-Defined Routines and Data Types Developer's Guide.
You can write the following types of C UDRs.
C UDRs provide the following benefits over UDRs written in SPL:
UDRs process data on the server computer and send just the results to the client application. This division of processing often reduces the amount of data that needs to be sent to the client application.
UDRs process just the data that needs to be processed depending on what the optimizer determines is most efficient.
C UDRs centralize shared code, which allows many users to access a single copy of the routine.
You can write a UDR in C by using the DataBlade API functions to communicate with the database server. You can also write subroutines in C that a UDR calls as it executes. These subroutines must follow the same rules as the UDR with respect to the use of DataBlade API functions.
You compile UDRs into shared-object files. You then register the UDR in the system catalog tables so that the database server can locate the code at runtime. The database server dynamically loads the shared-object files into memory when the UDR executes.
For more information on how to create C UDRs, see the following chapters of this manual: