0

I am executing following code:

simpleJdbcCall.withSchemaName("SCHEMA_NAME") .withProcedureName(storedProcdure) .addDeclaredParameter( new SqlParameter("INPUT_PARAMS",Types.LONGNVARCHAR));

// Creating String of input numbers
if (!loanNumbers.isEmpty()) {
    for (String str : paramsList)
        finalInput = finalInput + str + ";";
    finalInput = finalInput + "'";
}
// Preparing map of input params for Stored Procedure
inputParams.put("INPUT_PARAMS", finalInput);
log.info("Input params for Stored Procedure :"+finalInput);

//Input Prepared and finally calling Stored Procedure
SqlParameterSource in = new MapSqlParameterSource(inputParams);
Map<String, Object> resultSet= simpleJdbcCall.execute(in);

If FinalInput have only one value ie. '123467', SimpleJdbcCall will omit this first parameters and I will not get any result. If I run the same SP in any IDE , for the same param , I will get the result.

If it have more than two parameters i.e '123467;98768', it will omit the first parameters(123467) and give result for 98768.

What is the reason for this kind of behavior and how can we fix this.

Prax
  • 91
  • 3
  • 12
  • That might be something you need to lookup in the database it self. Is there a reason to think JDBC is causing it? – BrianC Mar 18 '19 at 20:57
  • If you have three or four parameters is it still skipping the first one, or is it that is only runs the last one? – BrianC Mar 18 '19 at 20:57
  • Thanks @BrianC , Suppose I have 4 parameters for SP then SimpleJdbcCall is skipping result for the first parameter given as input and for other 3 input params I am getting results. – Prax Mar 29 '19 at 06:09
  • I observe that also. the problematic code is here: ```for (SqlParameter parameter : this.callParameters) { if (!parameter.isResultsParameter()) { if (parameterCount > 0) { callString.append(", "); } if (parameterCount >= 0) { callString.append(createParameterBinding(parameter)); } parameterCount++; } }``` i do not know why in this code first parameter is just skip (parameterCount at the beginning is -1. – tmucha Aug 22 '19 at 14:17

0 Answers0