Application Building Guide

User-Defined Functions (UDFs)

UDFsrv demonstrates Java user-defined functions. Since UDF programs do not contain SQL statements, a Java UDF program cannot contain SQLJ statements. Once the UDFsrv libary is created on the server, it may be accessed by a client application. DB2 provides both a JDBC client application, UDFcli , and an SQLJ client application, UDFclie . Either can be used to access the UDFsrv library.

To build and run the UDF program on the server by commands entered at the command line:

  1. Compile UDFsrv.java to produce the file UDFsrv.class with this command:
       javac UDFsrv.java
    
  2. Copy UDFsrv.class to the %DB2PATH%\function directory on OS/2 and Windows 32-bit operating systems, or to the sqllib/function directory on UNIX.
  3. To access the UDFsrv library, you can use either JDBC or SQLJ client applications. To compile and run the JDBC client application, UDFcli, see "Client Applications for User-Defined Functions". To compile and run the SQLJ client application, UDFclie, see "Client Programs for User-Defined Functions".

UDFcli and UDFclie contain the CREATE FUNCTION SQL statement that you use to register the UDFs contained in UDFsrv with the database. UDFcli and UDFclie also contain SQL statements that make use of the UDFs, once they have been registered.


[ Top of Page | Previous Page | Next Page ]