I have an sql function (no idea about sql)
CREATE OR REPLACE FUNCTION RATELIMIT_OWN.Get_Conns_By_Login_IP_CallerId (p_yyyymm VARCHAR2, p_login VARCHAR2, p_framed_ip VARCHAR2, p_caller_id VARCHAR2 )
RETURN CONNECTION_RECORD_4_IPV6_TABLE PIPELINED IS
TYPE ref0 IS REF CURSOR;
cur0 ref0;
v_where_clause VARCHAR2(512);
out_rec CONNECTION_RECORD_4_IPV6 := connection_record_4_ipv6(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
BEGIN
if p_login is not NULL
then
v_where_clause := 'where login=''' || p_login || '''';
if p_framed_ip is not NULL
then
v_where_clause := v_where_clause || ' and framed_ip=''' || p_framed_ip || '''';
end if;
if p_caller_id is not NULL
then
v_where_clause := v_where_clause || ' and caller_id=''' || p_caller_id || '''';
end if;
else
v_where_clause := '';
if p_framed_ip is not NULL
then
v_where_clause := 'where framed_ip=''' || p_framed_ip || '''';
if p_caller_id is not NULL
then
v_where_clause := v_where_clause || ' and caller_id=''' || p_caller_id || '''';
end if;
else
if p_caller_id is not NULL
then
v_where_clause := 'where caller_id=''' || p_caller_id || '''';
end if;
end if;
end if;
OPEN cur0 FOR
'SELECT login,acct_ts_start,acct_ts_stop,cause,duration,inb,outb,framed_ip,caller_id,called_id,nas_id,radius_type,format_ipv6_prefix(framed_ipv6_prefix),format_ipv6_prefix(delegated_ipv6_prefix) from ticket partition (TICKETS_P' || p_yyyymm || ') ' || v_where_clause;
LOOP
FETCH cur0 INTO out_rec.login, out_rec.acct_start, out_rec.acct_stop, out_rec.cause, out_rec.duration, out_rec.in_bytes, out_rec.out_bytes, out_rec.public_ip, out_rec.caller_id, out_rec.called_id, out_rec.nas_id, out_rec.radius_type, out_rec.framed_ipv6_prefix, out_rec.delegated_ipv6_prefix;
EXIT WHEN cur0%NOTFOUND;
PIPE ROW(out_rec);
END LOOP;
CLOSE cur0;
RETURN;
END Get_Conns_By_Login_IP_CallerId;
/
I am calling this function using Spring JDBC template
SimpleJdbcCall caller = new SimpleJdbcCall(this.jdbcTemplateMartinique).withSchemaName("RATELIMIT_OWN").withFunctionName("Get_Conns_By_Login_IP_CallerId").withReturnValue()
.declareParameters(new SqlParameter(P_YYYYMM, Types.VARCHAR))
.declareParameters(new SqlParameter(P_LOGIN, Types.VARCHAR))
.declareParameters(new SqlParameter(P_FRAMED_IP, Types.VARCHAR))
.declareParameters(new SqlParameter(P_CALLER_ID, Types.VARCHAR));
SearchAccountBean resultBean = null;
SqlParameterSource paramMap = new MapSqlParameterSource().addValue(P_YYYYMM, searchAccountBean.getDate(), Types.VARCHAR).addValue(P_LOGIN, searchAccountBean.getLogin(), Types.VARCHAR)
.addValue(P_FRAMED_IP, searchAccountBean.getIpAddress(), Types.VARCHAR).addValue(P_CALLER_ID, searchAccountBean.getCaller(), Types.VARCHAR);
caller.compile();
Object result = caller.executeFunction(Object.class, paramMap);
Now it's throwing invalid column type 1111. I debugged and found it's returning "return of SQL type 1111".
I want to know how can i retrieve the values of function result in java.
It looks like something I solved just recently by registering "type handler" for an output parameter. The trick was registering SqlReturnType for SqlOutParameter - see constructor for SqlOutParamater. The interface has method getTypeValue() the allows you to process information from Oracle STRUCT which is likely the representation of your type in JDBC.
You can find more details here: http://rostislav-matl.blogspot.cz/2012/10/accessing-oracle-user-defined-type-with.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.