I have a stored procedure that takes 1 input value, 2 output parameters and also returns a value on execution
Over the internet i saw references using Call
CallableStatement cstmt = conn.prepareCall("{call ? = spName(?, ?, ?)}");
cstmt.registerOutParameter(1, Types.INTEGER);
cstmt.setObject(2, Types.INTEGER);
cstmt.registerOutParameter(3, Types.NVARCHAR);
cstmt.registerOutParameter(4, Types.NVARCHAR);
But this gives me the error
"Incorrect syntax near '{'"
Then i decided to do like the SQL Management Studio generated SQL code:
CallableStatement cstmt = conn.prepareCall("exec ? = spName ?, ?, ?");
cstmt.registerOutParameter(1, Types.INTEGER);
cstmt.setObject(2, Types.INTEGER);
cstmt.registerOutParameter(3, Types.NVARCHAR);
cstmt.registerOutParameter(4, Types.NVARCHAR);
But this gives me the error
"Incorrect syntax near '='"
I think this is because the query gets transformed to
"exec @P1 OUT = spName @P2, @P3 OUT, @P4 OUT"
and it doesn't work either on SQL Management Studio because 'OUT' appers before '='
And this leaves me without ideas because it doesn't work either way.
Any suggestions?
Thank you!