是否有一种更简单的方法来关闭PL/SQL程序(Oracle 10G)中的所有打开的游标。从pl/sql异常块中关闭所有游标'一次'
我有一个程序可以产生一些例外。要正常退出,我需要检查是否有 任何游标打开和关闭它们。这是我结束的那种情况。
Procedure test
is
--
---
Begin
--
--
Exception
when no_data_found then
if cursorA%isopen close
if cursorB%isopen close
if cursorC%isopen close
when invalid_date then
if cursorA%isopen close
if cursorB%isopen close
if cursorC%isopen close
when invalid_user then
if cursorA%isopen close
if cursorB%isopen close
if cursorC%isopen close
when others then
if cursorA%isopen close
if cursorB%isopen close
if cursorC%isopen close
End test;
很明显,以上并不理想,特别是如果有很多异常条款。与其对每个异常块执行相同的检查,是否有更快的方法来关闭所有打开的光标?注意:它只需要关闭由当前运行的pl/sql程序打开的游标,因为可能还有其他可能会打开游标的pl/sql程序。
在此先感谢
不太熟悉Oracle异常语法,但是您能否将所有的游标关闭语句放在一边测试您正在处理的异常类型? – n8wrl
否,因为发生异常时,控制权跳转到相关异常块的第一行。在某些情况下,我无法控制何时会引发异常。 – ziggy