Hi,
I got the following example to work.
On the Sql Server i created this stored procedure:
CREATE PROCEDURE [dbo].[output_param_test]
@inputParam varchar(100),
@outputParam varchar(100) OUTPUT
set @outputParam = @inputParam;
END
To get the output parameter from java with sql2o:
String sql =
"declare @outputParam as varchar(100) " +
"exec output_param_test @inputParam = :param, @outputParam = @outputParam OUTPUT " +
"select @outputParam as myval";
String outputVal = sql2o.createQuery(sql).addParameter("param", "foo").executeScalar(String.class);
assertThat(outputVal, is(equalTo("foo")));
If you need to fetch more than one output parameter, you can use executeAndFetchTable() method instead of the executeScalar() method.
Regards
Lars Aaberg