aaberg/sql2o — pull request #108 by aaberg (2014-04-17 18:44:07+00:00)
Title: ref #31, added stored procedure and output parameter support

Given the following PostgreSQL procedure:

CREATE OR REPLACE FUNCTION testfunc(IN arg1 integer, OUT arg2 integer, OUT arg3 integer)
RETURNS record AS
'select $1 + 1, $1 + 2'
LANGUAGE sql VOLATILE
COST 100;

Sql2o can call it like this:

final Integer inputArg = 20;

OutParameter p2 = new OutParameter("outParam2", Types.INTEGER, Integer.class);
OutParameter p3 = new OutParameter("outParam3", Types.INTEGER, Integer.class);

sql2o.createProcedureCall("{call testfunc (:inParam1,:outParam2,:outParam3)}")
.addParameter("inParam1", inputArg)
.addParameter(p2)
.addParameter(p3)
.executeUpdate();

int outParam2 = p2.getValue();
int outParam3 = p3.getValue();

Any comments?