diff --git a/core/src/java/scriptella/jdbc/SqlParserBase.java b/core/src/java/scriptella/jdbc/SqlParserBase.java index 58da5d35..c7ad129d 100644 --- a/core/src/java/scriptella/jdbc/SqlParserBase.java +++ b/core/src/java/scriptella/jdbc/SqlParserBase.java @@ -142,7 +142,7 @@ private void handleStatement(final String sql, * @return substituion string. */ protected String handleParameter(final String name, final boolean expression, final boolean jdbcParam) { - return expression ? ((jdbcParam ? "?{" : "${") + name + '}') : ((jdbcParam ? "?{" : "$") + name); + return expression ? ((jdbcParam ? "?{" : "${") + name + '}') : ((jdbcParam ? "?" : "$") + name); } /** diff --git a/core/src/test/scriptella/jdbc/SQLParserBaseTest.java b/core/src/test/scriptella/jdbc/SQLParserBaseTest.java index ceeb8a25..aae00e72 100644 --- a/core/src/test/scriptella/jdbc/SQLParserBaseTest.java +++ b/core/src/test/scriptella/jdbc/SQLParserBaseTest.java @@ -109,4 +109,28 @@ protected void statementParsed(String parsedSql) { } + public void testCallableStatement() { + final String sql = "{call procName(?arg1, ?out_arg2, ?inout_arg3, 'value')}"; + + SqlParserBase p = new SqlParserBase() { + String[] paramNames = {"arg1", "out_arg2", "inout_arg3"}; + int paramNumber; + @Override + protected String handleParameter(final String name, final boolean expression, boolean jdbcParam) { + assertEquals(paramNames[paramNumber], name); + assertFalse(expression); + assertTrue(jdbcParam); + paramNumber++; + String s = super.handleParameter(name, expression, jdbcParam); + return s; + } + + @Override + protected void statementParsed(String parsedSql) { + assertEquals(sql, parsedSql); + } + }; + p.parse(new StringReader(sql)); + } + }