I'm new to spring boot development and java.
I'm here trying to call the Oracle PLSQL function from spring boot with the help of simpleJdbcCall.executeFunction method. My plsql function is returning the single table row. In java i'm trying to store the result/output of function in Map data type, but whenever i'm trying to run the application i'm getting error as mentioned below
PLSQL function:
CREATE TABLE test.account1 (
account_id INT,
name VARCHAR2(20)
);
INSERT INTO test.account1 VALUES ( 1, 'Bob' );
INSERT INTO test.account1 VALUES ( 2, 'Nob' );
create or replace function test.get_accounts
(Acc_id in Account1.account_id%Type)
return account1%rowtype
as
l_cust_record account1%rowtype;
begin
select * into l_cust_record from account1
where account_id=Acc_id;
return(l_cust_record);
end;
/
Java method:
@SuppressWarnings("unchecked")
public void testFunctionTablerow(){
this.jdbcTemplate =new JdbcTemplate(datasource);
System.out.println("1");
simpleJdbcCall = new SimpleJdbcCall(jdbcTemplate).withFunctionName("get_accounts");
System.out.println("2");
SqlParameterSource in= new MapSqlParameterSource().addValue("Acc_id", 1);
System.out.println("3");
//Map<String, Object> out = simpleJdbcCall.executeFunction(Map.class, in);
Map<String, Object> out= simpleJdbcCall.executeFunction(Map.class, in);
System.out.println(out);
}
error:
2018-07-12 12:18:34.620 INFO 1560 --- [nio-8000-exec-2] o.s.b.f.xml.XmlBeanDefinitionReader : Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
2018-07-12 12:18:34.669 INFO 1560 --- [nio-8000-exec-2] o.s.jdbc.support.SQLErrorCodesFactory : SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase, Hana]
Can you please help me and let me know what is the correct method to store the value of plsql function ouput in java whenever function is returning entire row. Please share if you know any other method to call such type of function which returns complex output.
Thank you
INFOlog that don't have anything to do with any errors.