Calling Stored Procedures - novus/novus-jdbc GitHub Wiki

Support for calling stored procedures has been built into the library in two main flavors: those that return OUT parameters and those that return a standard ResultSet. Stored procedures with both OUT parameters and query statements are not supported. This decision reduces library complexity at both the implementation and use-case scenario level.

Retrieving Stored Procedure Results

Much like the five CRUD query methods, the result of a stored procedure call is to return an Iterator containing the parsed contents of the underlying ResultSet. Each iteration through the returned Iterator causes the evaluation of the next row.

Stored procedures are called using the "proc" member function of the QueryExecutor:

val output = executor.proc("EXEC my_stored_proc(?, ?)", arg1, arg2){ row =>
  (row getString "foo", row getInt "bar")
}

Working with OUT parameters

Stored procedures can also be called with OUT parameters. Instead of returning a ResultSet, a finite collection of values are returned through the calling statement. These are accessed in an almost identical manner as the CRUD query methods.

val output = executor.proc(Array["foo"],"EXEC my_proc"){ result =>
  result getInt "foo"
}

Unlike the selectOne method, calling a stored procedure with OUT parameters expects that the stored procedure will return results.