Hi,
For the following oracle stp
--PL/SQL procedure
CREATE OR REPLACE PROCEDURE get_resultset(
ret_cursor OUT SYS_REFCURSOR )IS
BEGIN
OPEN ret_cursor FOR
'SELECT * FROM my_table' ;
END;
/
this StoredProcedureItemReader works fine ...
<bean id="pupilItemReader" class="org.springframework.batch.item.database.Sto redProcedureItemReader" scope="step" >
<property name="dataSource" ref="dataSource"/>
<property name="procedureName" value="get_resultset"/>
<property name="parameters">
<list>
<bean class="org.springframework.jdbc.core.SqlOutParamet er">
<constructor-arg index="0" value="newid"/>
<constructor-arg index="1">
<util:constant static-field="oracle.jdbc.OracleTypes.CURSOR"/>
</constructor-arg>
</bean>
</list>
</property>
<property name="refCursorPosition" value="1"/>
<property name="rowMapper">
<bean class="ie.gov.edu.ppod.batch.database.PupilRowMapp er"/>
</property>
</bean>
However when adding an IN parameter to the stp
--PL/SQL procedure
CREATE OR REPLACE PROCEDURE get_resultset(
ret_cursor OUT SYS_REFCURSOR,IS
roll_no IN VARCHAR )
BEGIN
OPEN ret_cursor FOR
'SELECT * FROM my_table where ROLL_NO =' ||roll_no;
END;
/
this StoredProcedureItemReader does not works ...
<bean id="pupilItemReader" class="org.springframework.batch.item.database.Sto redProcedureItemReader" scope="step" >
<property name="dataSource" ref="dataSource"/>
<property name="procedureName" value="get_resultset"/>
<property name="parameters">
<list>
<bean class="org.springframework.jdbc.core.SqlOutParamet er">
<constructor-arg index="0" value="newid"/>
<constructor-arg index="1">
<util:constant static-field="oracle.jdbc.OracleTypes.CURSOR"/>
</constructor-arg>
</bean>
<bean class="org.springframework.jdbc.core.SqlParameter" >
<constructor-arg index="0" value="123456"/>
<constructor-arg index="1">
<util:constant static-field="java.sql.Types.VARCHAR"/>
</constructor-arg>
</bean>
</list>
</property>
<property name="refCursorPosition" value="1"/>
<property name="rowMapper">
<bean class="ie.gov.edu.ppod.batch.database.PupilRowMapp er"/>
</property>
</bean>
I'm getting the following error
Caused by: java.sql.SQLException: Missing IN or OUT parameter at index:: 2
I have the following questions
- Why are there two constructor-args per sqlparameter?
- What does the index property of the constructor-arg parameter mean? I tried various combos.
Any help greatly appreciated! I'm very confused.
An end-to-end example of an stp with an IN & OUT example would be great.
Thanks in advance ....
Kevin


Reply With Quote