I am going to call a function and set some parameters by name, for example:
Connection c = null; ResultSet rs = null; String query; PreparedStatement ps; CallableStatement cs = null; try { c = DbUtils.getConnection(); cs = c.prepareCall("{? = call get_proc_name(?, ?) }"); cs.registerOutParameter(1, OracleTypes.VARCHAR); cs.setInt("in_proc_type", ProcTypes.SELECT); cs.setLong("in_table_id", tableId);
Parameters of the PL / SQL function:
CREATE OR REPLACE FUNCTION get_proc_name ( in_proc_type IN NUMBER, in_table_name IN VARCHAR2 := NULL, in_table_id IN NUMBER := NULL, in_table_type_id IN NUMBER := NULL, is_new IN NUMBER := 0 ) RETURN VARCHAR2
The question is how to register the result as an out parameter, and then get it from oracle in java? I can register I / O parameters by name, because I know their names from the function, but I don’t know how to go get the result of the function, which variable name to use for it.
The manuals describe only in / out usage parameters with procedures, not functions.
Oracle Version: 11.1.0.6.0 Java Version: 1.6.0_14
source share