1

我面临一个奇怪的问题。

我创建了一个 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;
4

0 回答 0