java.sql.SQLException: ORA-06550: line 1, column 8: PLS-00103: Encountered the symbol "?" when expecting one of the following: begin case declare ...
String procedure = "{call sajet.test_levi(?)}";
CallableStatement cstmt = conn.prepareCall(procedure);
cstmt.setString(1, customer);
cstmt.execute();
Oracle JDBC 驅動在調用 不帶 OUT 參數的存儲過程 時,要求使用匿名 PL/SQL 塊語法:BEGIN procedure_name(?); END;。直接使用 {call ...} 會導致解析器無法識別參數佔位符。
CallableStatement cstmt = conn.prepareCall("BEGIN sajet.test_levi(?); END;");
cstmt.setString(1, "sssss");
cstmt.execute();
加上 BEGIN ... END; 後即可正常執行,無需修改存儲過程定義。