Chapter 4. Simplifying Application Development


Home » Documentation » Using VoltDB

Chapter 4. Simplifying Application Development

The previous chapter (Chapter 3, Designing Your VoltDB Application) explains how to develop your VoltDB database application using the full power and flexibility of the Java client interface. However, some database tasks — such as inserting records into a table or retrieving a specific column value — do not need all of the capabilities that the Java API provides.

Now that you know how the VoltDB programming interface works, VoltDB has features to simplify common tasks and make your application development easier. Those features include:

  1. Default procedures

  2. Shortcuts for defining simple stored procedures

  3. Verifying expected SQL query results

The following sections describe each of these features separately.

4.1. Default Procedures

Although it is possible to define quite complex SQL queries, often the simplest are also the most common. Inserting, selecting, updating, and deleting records based on a specific key value are the most basic operations for a database. Another common practice is upsert, where if a row matching the primary key already exists, the record is updated — if not, a new record is inserted.

To simplify these operations, VoltDB defines default stored procedures to perform these queries for any table with a primary key index. It also defines a default insert stored procedure for tables without a primary key. When you compile the application catalog, these default procedures are added to the catalog automatically.

The default stored procedures use a standard naming scheme, where the name of the procedure is composed of the name of the table (in all uppercase), a period, and the name of the query in lowercase. The parameters to the procedures differ based on the procedure. For the insert procedure, the parameters are the columns of the table, in the same order as defined in the schema. For the select and delete procedures, only the primary key column values are required (listed in the order they appear in the primary key definition). For the update and upsert procedures, the columns are the new column values, in the order defined by the schema, followed by the primary key column values. (This means the primary key column values are specified twice: once as their corresponding new column values and once as the primary key value.)

For example, the Hello World tutorial contains a single table, HELLOWORLD, with three columns and the partitioning column, DIALECT, as the primary key. As a result, the application catalog includes six default stored procedures, in addition to any user-defined procedures declared in the schema. Those default procedures are:

  • HELLOWORLD.insert


  • HELLOWORLD.update

  • HELLOWORLD.upsert

  • HELLOWORLD.delete

The following code example uses the default procedures for the HELLOWORLD table to insert, retrieve, update, and delete a new record with the key value "American":

VoltTable[] results;
results = client.callProcedure("",