【发布时间】:2011-11-03 16:28:35
【问题描述】:
有没有一种更简单的方法可以从 PL/SQL 程序 (Oracle 10G) 中关闭所有打开的游标。
我有一个可以产生许多异常的程序。要正确退出,我需要检查是否有 任何游标打开和关闭它们。这就是我最终遇到的情况。
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 Exception 语法,但是您能否在测试您正在处理的异常类型之前将所有游标关闭语句?
-
否,因为当引发异常时,控制跳转到相关异常块的第一行。在某些情况下,我无法控制何时引发异常。
标签: sql oracle plsql oracle10g