I am struggling with the code below to make it work, look for documentation and forums, and get stuck. Finally, I decided to ask you for help. I have a package with TYPES, FUNCTION declarations and a FUNCTION BODY declaration. In the future I would like to use SYNONYM for MYPACKAGE (this is just a layout - I will not have package and type declarations in my database, but use dblink for the external database and Java code to run the procedures / functions, but now I do not have this available dblink), and MYPACKAGE will be available through dblink:
create public synonym dblink_MYPACKAGE for SOME_SCHEMA.MYPACKAGE@dblink _externalDB;
and I will use dblink_MYPACKAGE instead of MYPACKAGE in Java Code. (but it doesnβt matter, does it?) The external database is not ours, so we canβt change anything there ...
public class TestClassSpringBased { private DataSource dataSource; private SimpleJdbcCall jdbcCall; @Override public void testMe(Integer id) { int iid = 1; SqlParameterSource in = new MapSqlParameterSource().addValue("IN_1", iid); Map<String, Object> out = jdbcCall.execute(in); } public DataSource getDataSource() { return dataSource; } public void setDataSource(DataSource dataSource) { this.dataSource = dataSource; JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); jdbcTemplate.setResultsMapCaseInsensitive(true); this.jdbcCall = new SimpleJdbcCall(dataSource) .withCatalogName("MYPACKAGE") .withProcedureName("MYFUNCTION") .withReturnValue() .useInParameterNames("IN_1") .declareParameters( new SqlInOutParameter("IN_1", OracleTypes.NUMBER), new SqlInOutParameter("OUT_1", OracleTypes.STRUCT, "MYPACKAGE.CUSTOMELEMENTSTYPE", new SqlReturnType() { public Object getTypeValue(CallableStatement cs, int colIndx, int sqlType, String typeName) throws SQLException { return null;
ERROR: org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; unategorized SQLException for SQL [{? = call MYPACKAGE.MYFUNCTION (?,?)}]; SQL State [99999]; error code [17074]; invalid name pattern: MYPACKAGE.CUSTOMELEMENTSTYPE; nested exception - java.sql.SQLException: invalid name pattern: MYPACKAGE.CUSTOMELEMENTSTYPE
The problem is only with the OUT parameter, the same code works when I do not pass the OUT parameter and run it against another version of MYFUNCTION, which does not have the OUT parameter.
I also tried using OracleTypes.ARRAY (wrong name pattern) and OracleTypes.OTHER (called: java.sql.SQLException: wrong column type: 1111)
user1308908
source share