I'm having trouble invoking an SQL function in Oracle using the Spring
SqlFunction wrapper. Here is a snippet from the JDBC invocation.
I've tried various combinations the SQL string and parameter declarationsCode:call = conn.prepareCall("{? = call pkg_product.f_id_from_upc(?)}"); call.registerOutParameter(1, OracleTypes.NUMERIC); call.setString(2, upcNo); call.execute(); uniqueProductId = (long) call.getLong(1); call.execute();
to no avail. I was attempting to subclass SqlFunction with a constructor like this.
But my invocationCode:public MySqlFunction(DataSource ds) { super(ds, "call pkg_product.f_id_from_upc(?)", new int[] {Types.VARCHAR} ); compile(); }
I get the errorCode:MySqlFunction sf = new MySqlFunction(ds); Object o = sf.runGeneric(new String[] {"xyz"});
But I'm pretty sure the function name is correct. If I add the leading question mark to the SQL statement:Code:org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [call pkg_product.f_id_from_upc(?)]; nested exception is java.sql.SQLException: ORA-06576: not a valid function or procedure name
it will complain that I have not passed in enough parameters. But the first parameter would be an OUT parameter. I'm not sure how to do that with SqlFunction.Code:? = call pkg_product.f_id_from_upc(?)


Reply With Quote