I'm trying to write an integration test for a DAO that calls a stored procedure. I've created an embedded HSQL database from a test file that simply creates a table, populates it, and a simple stored procedure that returns the results of the table:
CREATE PROCEDURE usp_GetAvailableServices()
READS SQL DATA
BEGIN ATOMIC
DECLARE result CURSOR WITH RETURN FOR SELECT FeatureType FROM PUBLIC.service_areas ;
OPEN result;
END/;
The code to create the database is as follows. The database is created and populated properly.
db = new EmbeddedDatabaseBuilder()
.setType(EmbeddedDatabaseType.HSQL)
.addScript("db/sql/getAvailableServicesStoredProcedure.sql")
.setSeparator("/;")
.build();
My test fails when trying to call the stored procedure with General error; nested exception is java.sql.SQLException: General error
which is ultimately caused by
Caused by: org.hsqldb.HsqlException: General error
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
...
I got the HSQLDB console running and confirmed that my stored procedure was indeed created (it is listed under information_schema.routines
), however when I try calling the stored procedure directly in the console with call usp_GetAvailableServices()
, I am still presented with General error / Error Code: -458 / State: S1000
This leads me to believe that I have an error in my create procedure syntax, (seems correct per http://hsqldb.org/doc/2.0/guide/sqlroutines-chapt.html#src_psm_cursors) or that I don't know how to properly call a routine in HSQLDB.
The code that calls the live stored procedure using SqlServer works properly. It's only HSQLDB that doesn't work.