使用Hibernate调用Oracle存储过程时出现问题 - ORA-01001:游标无效

时间:2013-10-28 17:14:13

标签: oracle hibernate plsql cursor

我面临一个奇怪的问题。

我已经创建了一个oracle存储过程并在SQL Developer中进行了测试,它运行正常。

现在,当我尝试使用Hibernate 3调用它时,它显示了下面提到的错误消息。有人可以帮助我,我错过了什么?它所指的行号指向myCursor2被关闭的行。

Caused by: java.sql.SQLException: ORA-01001: invalid cursor
ORA-06512: at "MystoredProcedure", line 56

我的存储过程如下所示。

create or replace PROCEDURE MystoredProcedure (
    four input arguemnts and 
     one output variable all are numbers
) AS 
  cursor myCursor2 is
     select statement;
  CURSOR myCursor1 is
     select statement;
  Variables to hold data  
BEGIN
  OPEN myCursor1;      
  LOOP
      FETCH myCursor1 into variables;
      EXIT WHEN myCursor1%NOTFOUND;

        insert data into a set of tables.

      OPEN myCursor2;
      LOOP
          FETCH myCursor2 into variables;
          EXIT WHEN myCursor2%NOTFOUND;
          insert data into some other tables
      END LOOP;  

  end Loop;
  insert into another table

  CLOSE myCursor2;
  CLOSE myCursor1;

END MystoredProcedure;

0 个答案:

没有答案