External Functions

About this task

External functions are functions you write in an external language (that is, a programming language other than SPL) that Informix® supports.

To create a C user-defined function

Procedure

  1. Write the C function.
  2. Compile the function and store the compiled code in a shared library (the shared-object file for C).
  3. Register the function in the database server with the CREATE FUNCTION statement.

Results

To create a user-defined function written in the Java language

  1. Write a Java static method, which can use the JDBC functions to interact with the database server.
  2. Compile the Java source file and create a .jar file (the shared-object file for Java).
  3. Execute the install_jar( ) procedure with the EXECUTE PROCEDURE statement to install the JAR file in the current database.
  4. If the UDR uses user-defined data types, create a map between SQL data types and Java classes. Use the setUDTextName( ) procedure that is explained in EXECUTE PROCEDURE statement.
  5. Register the UDR with the CREATE FUNCTION statement.

Rather than storing the body of an external routine directly in the database, the database server stores only the pathname of the shared-object file that contains the compiled version of the routine. When it executes the external routine, the database server invokes the external object code.

The database server stores information about an external function in system catalog tables, including sysprocbody and sysprocauth. For more information on the system catalog, see the Informix® Guide to SQL: Reference.