2222import java .util .TimeZone ;
2323import java .util .UUID ;
2424
25+ import org .junit .Assert ;
2526import org .junit .jupiter .api .AfterAll ;
2627import org .junit .jupiter .api .BeforeAll ;
2728import org .junit .jupiter .api .Tag ;
@@ -57,6 +58,8 @@ public class CallableStatementTest extends AbstractTest {
5758 .escapeIdentifier (RandomUtil .getIdentifier ("CallableStatementTest_inputParams_SP" ));
5859 private static String conditionalSproc = AbstractSQLGenerator
5960 .escapeIdentifier (RandomUtil .getIdentifier ("CallableStatementTest_conditionalSproc" ));
61+ private static String simpleRetValSproc = AbstractSQLGenerator
62+ .escapeIdentifier (RandomUtil .getIdentifier ("CallableStatementTest_simpleSproc" ));
6063 private static String getObjectLocalDateTimeProcedureName = AbstractSQLGenerator
6164 .escapeIdentifier (RandomUtil .getIdentifier ("CallableStatementTest_getObjectLocalDateTime_SP" ));
6265 private static String getObjectOffsetDateTimeProcedureName = AbstractSQLGenerator
@@ -100,6 +103,7 @@ public static void setupTest() throws Exception {
100103 TestUtils .dropProcedureIfExists (outOfOrderSproc , stmt );
101104 TestUtils .dropProcedureIfExists (byParamNameSproc , stmt );
102105 TestUtils .dropProcedureIfExists (conditionalSproc , stmt );
106+ TestUtils .dropProcedureIfExists (simpleRetValSproc , stmt );
103107 TestUtils .dropFunctionIfExists (userDefinedFunction , stmt );
104108 TestUtils .dropUserDefinedTypeIfExists (manyParamUserDefinedType , stmt );
105109 TestUtils .dropProcedureIfExists (manyParamProc , stmt );
@@ -119,6 +123,7 @@ public static void setupTest() throws Exception {
119123 createOutOfOrderSproc ();
120124 createByParamNameSproc ();
121125 createConditionalProcedure ();
126+ createSimpleRetValSproc ();
122127 createUserDefinedFunction ();
123128 }
124129 }
@@ -1197,6 +1202,21 @@ public void testCallableStatementDefaultValues() throws SQLException {
11971202 }
11981203 }
11991204
1205+ @ Test
1206+ public void testCallableStatementSetByAnnotatedArgs () throws SQLException {
1207+ String call = "{? = call " + simpleRetValSproc + " (@Arg1 = ?)}" ;
1208+ int expectedValue = 1 ; // The sproc should return this value
1209+
1210+ try (CallableStatement cstmt = connection .prepareCall (call )) {
1211+ cstmt .registerOutParameter (1 , Types .INTEGER );
1212+ cstmt .setInt (1 , 2 );
1213+ cstmt .setString (2 , "foo" );
1214+ cstmt .execute ();
1215+
1216+ Assert .assertEquals (expectedValue , cstmt .getInt (1 ));
1217+ }
1218+ }
1219+
12001220 @ Test
12011221 @ Tag (Constants .reqExternalSetup )
12021222 @ Tag (Constants .xAzureSQLDB )
@@ -1305,6 +1325,7 @@ public static void cleanup() throws SQLException {
13051325 TestUtils .dropProcedureIfExists (byParamNameSproc , stmt );
13061326 TestUtils .dropProcedureIfExists (currentTimeProc , stmt );
13071327 TestUtils .dropProcedureIfExists (conditionalSproc , stmt );
1328+ TestUtils .dropProcedureIfExists (simpleRetValSproc , stmt );
13081329 TestUtils .dropFunctionIfExists (userDefinedFunction , stmt );
13091330 }
13101331 }
@@ -1373,6 +1394,13 @@ private static void createConditionalProcedure() throws SQLException {
13731394 }
13741395 }
13751396
1397+ private static void createSimpleRetValSproc () throws SQLException {
1398+ String sql = "CREATE PROCEDURE " + simpleRetValSproc + " (@Arg1 VARCHAR(128)) AS DECLARE @ReturnCode INT RETURN 1" ;
1399+ try (Statement stmt = connection .createStatement ()) {
1400+ stmt .execute (sql );
1401+ }
1402+ }
1403+
13761404 private static void createTableManyParams () throws SQLException {
13771405 String type = manyParamUserDefinedType ;
13781406 String sql = "CREATE TABLE" + manyParamsTable + " (c1 " + type + " null, " + "c2 " + type + " null, " + "c3 "
0 commit comments