I've been trying to find a way to make stored proc calls from Spring 3.0 to Oracle 11.2 with following the items in mind:
- Many of the calls are made to stored procedures that have plethora of optional parameters (parameters that have default values).
- There are stored procedures that can have a mix of:
IN,OUT, and/orIN OUT. - I do not need to handle the
OUT's.
I would like to be able to call a stored proc with the needed parameters (required and/or optional). In other word, I do not wish to pass a value (not even a null) to optional parameters to my choosing (it seems like when null is being passed programmatically [not in PL/SQL though] to a parameter mapper, the default values don't get used). I have attempted to implement these invocations as many possible ways as I could but nothing has worked:
create or replace procedure update_stored_proc ( h1 in boolean default false, h2 in number, h3 in varchar2 default 'H3', h4 in varchar2 default 'H4', h5 in varchar2 default 'H5', h6 in out number ); For update_stored_proc(), there is only two required parameters (h2 and h6), and four optional ones. My ultimate goal is to call update_stored_proc() by passing h1, h2 and h6. Even when I invoking the stored proc via SimpleJdbcCall with all the values set, I get an exception:
SimpleJdbcCall simpleJdbcCall = new SimpleJdbcCall(updatingDataSource) .withProcedureName("update_stored_proc") .withoutProcedureColumnMetaDataAccess(); simpleJdbcCall.declareParameters(new SqlParameter("h1", OracleTypes.BOOLEAN)) .declareParameters(new SqlParameter("h2", OracleTypes.NUMBER)) .declareParameters(new SqlParameter("h3", OracleTypes.VARCHAR)) .declareParameters(new SqlParameter("h4", OracleTypes.VARCHAR)) .declareParameters(new SqlParameter("h5", OracleTypes.VARCHAR)) .declareParameters(new SqlInOutParameter("h6", OracleTypes.NUMBER)); MapSqlParameterSource in = new MapSqlParameterSource() .addValue("h1", false, OracleTypes.BOOLEAN) .addValue("h2", 123, OracleTypes.NUMBER) .addValue("h3", "h3", OracleTypes.VARCHAR) .addValue("h4", "h4", OracleTypes.VARCHAR) .addValue("h5", "h5", OracleTypes.VARCHAR) .addValue("h6", "h6", OracleTypes.NUMBER); simpleJdbcCall.compile(); simpleJdbcCall.execute(in); The exception I get indicates that the column type is somehow invalid:
org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{call update_stored_proc(?, ?, ?, ?, ?, ?)}]; SQL state [99999]; error code [17004]; Invalid column type; nested exception is java.sql.SQLException: Invalid column type I have replaced OracleTypes with Types and even taken out withoutProcedureColumnMetaDataAccess() but the error persists.