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.

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

It's for stored procedures right. How can we apply this for SQL Functions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.