on 2022 Jan 26 4:46 PM
My Procedure is something like :
PROCEDURE SAMPLE(
IN EMP_DATA COM_SAP_EMP,
IN ID INTEGER,
IN AGE INTEGER,
OUT RESULT TABLE("ABC" NVARCHAR(10),
"DEF" NVARCHAR(10),
"GHI" NVARCHAR(20))
) READS SQL DATA AS
BEGIN
I need to call it from my CAP Java project but couldn't
find any, how can i get the result out of the execution of this procedure,
as to get that we have to register the out parameter as below:
callableStatement.registerOutParameter("RESULT", Types.???);
Here I had tried with what all possible values of Types.__ available.
Request clarification before answering.
Hi Arun, Have you find any solution for this problem ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi everybody,
i managed to find a way, how to do it. Hope it will help somebody. So you need to set result type to Types.OTHER and then set value to "null".
Than check in debugger the name of returned array (in my case it was "#result-set-1") and loop through it
SimpleJdbcCall simpleJdbcCall = new SimpleJdbcCall(jdbcTemplate)
.withProcedureName(ProcedureName.PROCEDURE_NAME)
.declareParameters(new SqlParameter("FIRST", Types.VARCHAR),
new SqlParameter("SECOND", Types.VARCHAR),
new SqlParameter("RESULT", Types.OTHER));
Map<String, Object> inParamMap = new HashMap<>();
inParamMap.put("FIRST", "example");
inParamMap.put("SECOND", "example2");
inParamMap.put("RESULT", null);
SqlParameterSource in = new MapSqlParameterSource(inParamMap);
var simpleJdbcCallResult = simpleJdbcCall.execute(in);
ArrayList<Map<String, Object>> result = (ArrayList<Map<String, Object>>) simpleJdbcCallResult
.get("#result-set-1");
for (Map<String, Object> resultRow : result) {
var a = (Double) resultRow.get("RESULT_PARAM1");
var b = (Double) resultRow.get("RESULT_PARAM2");
...
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 6 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.