2

I have an sql function in the database

FUNCTION RATELIMIT_OWN.Get_Logs ( p_yyyymm VARCHAR2, p_numec NUMBER )

the function returns

TYPE RATELIMIT_OWN.LOG_RECORD AS OBJECT
   (EVENTID              VARCHAR2(15),
    MSG                    VARCHAR2(2000),
    CREATE_DATE      DATE);

I am new to stored procedures and sql functions. After looking at query in the function, it may return multiple results.

I am using Spring JDBC to execute and fetch the results.

 SimpleJdbcCall caller = new SimpleJdbcCall(this.jdbcTemplate).withFunctionName("RATELIMIT_OWN.Get_Logs");
    MyBean resultBean = null;

    MapSqlParameterSource paramMap = new MapSqlParameterSource();
    paramMap.addValue("p_yyyymm", inputBean.getMonth(), Types.VARCHAR);
    paramMap.addValue("p_numec", inputBean.getNumec(), Types.INTEGER);

    resultBean = caller.executeFunction(MyBean.class, paramMap);

But does this work? if I get multiple results, how does this work. It should return List right. I couldn't find any SimpleJdbcCall method to return List of objects and even no method through which I can pass RowMapper to map the returning columns to Bean.

RaceBase
  • 18,428
  • 47
  • 141
  • 202

1 Answers1

2

You may use JDBCTemplate's query method which will return a collection as expected. Also lets you specify a row mapper. Check this tutorial part 1 and tutorial part 2

Cid
  • 1,453
  • 1
  • 18
  • 37