閱讀REF_CURSOR我嘗試調用存儲過程無法與StoredProcedureItemReader
create or replace PROCEDURE "PROC"(cur OUT SYS_REFCURSOR)
與這個bean。
@Bean
StoredProcedureItemReader<?> itemReader() {
StoredProcedureItemReader<?> storedProcedureItemReader = new StoredProcedureItemReader<>();
storedProcedureItemReader.setDataSource(dataSource);
storedProcedureItemReader.setProcedureName("PROC");
storedProcedureItemReader.setRefCursorPosition(1);
storedProcedureItemReader.setRowMapper(new ColumnMapRowMapper());
storedProcedureItemReader.open(new ExecutionContext());
return storedProcedureItemReader;
}
,但我得到
org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:134)
... 54 more
Caused by: java.sql.SQLException: Invalid column index
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameterInternal(OracleCallableStatement.java:125)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:304)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:393)
at oracle.jdbc.driver.OracleCallableStatementWrapper.registerOutParameter(OracleCallableStatementWrapper.java:1569)
at org.springframework.batch.item.database.StoredProcedureItemReader.openCursor(StoredProcedureItemReader.java:202)
... 56 more
我怎麼能說只有一個PROC出光標,並得到重複的結果?
請更新您的答案並提供更多詳細信息,只有代碼答案沒有那麼有用+花時間格式化 –