6.2. Invoking Stored Procedures


VoltDB Home » Documentation » Using VoltDB

6.2. Invoking Stored Procedures

After your client creates the connection to the database, it is ready to call the stored procedures. You invoke a stored procedure using the callProcedure() method, passing the procedure name and variables as arguments. For example:

VoltTable[] results;
try { results = client.callProcedure("LookupFlight",              1
                                     departtime).getResults();    2
} catch (Exception e) {                                           3


The callProcedure() method takes the procedure name and the procedure's variables as arguments. The LookupFlight() stored procedure requires three variables: the originating airport, the destination, and the departure time.


Once a synchronous call completes, you can evaluate the results of the stored procedure. The callProcedure() method returns a ClientResponse object, which includes information about the success or failure of the stored procedure. To retrieve the actual return values you use the getResults() method. See Section 5.2.4, “Interpreting the Results of SQL Queries” for more information about interpreting the results of VoltDB stored procedures.


Note that since callProcedure() can throw an exception (such as VoltAbortException) it is a good practice to perform error handling and catch known exceptions.