8.2. Loading a User-Defined Function into the Database

Documentation

VoltDB Home » Documentation » Guide to Performance and Customization

8.2. Loading a User-Defined Function into the Database

Once you have written, compiled, and tested the Java code for your SQL function, you can load it into the database. You load user-defined functions the same way you load stored procedures, by packaging the Java class or classes into a JAR file and then loading the JAR file using the LOAD CLASSES statement. For example:

$ export CLASSPATH="$CLASSPATH:/opt/voltdb/voltdb/*"
$ javac -d ./obj src/myapp/functions/*.java
$ jar cvf myfunctions.jar -C obj .
$ sqlcmd
1> load classes myfunctions.jar;

You can package multiple function methods or a combination of functions and stored procedure classes into a single JAR file. The key is that you must load the class containing the function method into the database before you can declare the SQL function.