You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Anta <an...@gmail.com> on 2009/08/26 11:34:35 UTC
Calling oracle procedure from Java using iBatis
<PRE>
Hi All,
I have a stored procedure as like below in oracle db
create or replace PROCEDURE employee_to_delete (i_condition VARCHAR2)
IS
TYPE r_cursor IS REF CURSOR;
actiontype VARCHAR2 (20) := 'DELETING';
del_cur_temp r_cursor;
cursor_table employee%ROWTYPE;
sql_stmt VARCHAR2 (10000);
BEGIN
sql_stmt := 'select * from employee ' || i_condition;
OPEN del_cur_temp FOR sql_stmt;
LOOP
FETCH del_cur_temp
INTO cursor_table;
DELETE FROM employee
WHERE name = cursor_table.name
AND no = cursor_table.no
AND dept = cursor_table.dept;
EXIT WHEN del_cur_temp%NOTFOUND;
END LOOP;
commit;
END;
I have add the following line in my sql map file
<procedure id="deleteUser" parameterClass="string" >
<![CDATA[
{call employee_to_delete('where name like ''$value$'')}
]]>
</procedure>
And I tried to execute the same using the following java code
String str= "pavan";
sqlMap.queryForObject("deleteUser",str);
The records are deleted successfully. After that I am getting the exception
like below.
Exception in thread "main"
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in SqlMap.xml.
--- The error occurred while applying a parameter map.
--- Check the deleteUser-InlineParameterMap.
--- Check the output parameters.
--- Cause: java.lang.ArrayIndexOutOfBoundsException: 0
at
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:204)
at
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForObject(MappedStatement.java:120)
at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:518)
at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:493)
at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)
at
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:82)
at Main.main(Main.java:16)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at
com.ibatis.sqlmap.engine.exchange.PrimitiveDataExchange.setData(PrimitiveDataExchange.java:51)
at
com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap.refreshParameterObjectValues(ParameterMap.java:141)
at
com.ibatis.sqlmap.engine.mapping.statement.ProcedureStatement.postProcessParameterObject(ProcedureStatement.java:26)
at
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:193)
... 6 more
Please any one explain me why this exception occurs also how to solve it.
Thanks in Advance
Ant
</PRE>
--
View this message in context: http://www.nabble.com/Calling-oracle-procedure-from-Java-using-iBatis-tp25149494p25149494.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org