I want to execute a Oracle Stored procedure using named parameter from Java CollableStatement. Syntactically all is good by when we execute the application we get SQL Error-
Java Code -
int method1(){
CallableStatement stmt stmt = connection.prepareCall("{call "+strSQL.toString()+"}");
sp_copy_my_tree(?,?,?)
stmt.setInt("src_cd_ekey", 2057);
stmt.setInt("trg_ef_ekey", 8222);
stmt.setInt("trg_display_order", 1]);
returnValue = stmt.executeUpdate(strSQL.toString());
return returnValue ;
}
Oracle Stored Procedure -
create or replace PROCEDURE sp_copy_my_tree (src_ab_ekey IN NUMBER DEFAULT NULL,
src_cd_ekey IN NUMBER DEFAULT NULL, trg_ef_ekey IN NUMBER DEFAULT NULL,
trg_gh_ekey IN NUMBER DEFAULT NULL, trg_display_order IN NUMBER)
IS
begin
--- Some PL/SQL code ---
END ;
When I execute the above java statement I am getting Exception -
*java.sql.SQLException: Attempt to set a parameter name that does not occur in the SQL: src_cd_ekey*
Note- I have also tried to pass all the parameters in the same order of procedure, where for other 2 parameters I have passed null. But still getting the same Exception.
Please somebody help us to resolve this issue.
Try this method:
See documentation for details: http://docs.oracle.com/cd/E11882_01/java.112/e16548/getsta.htm#i1008346