从 Coldfusion 中关闭引用游标
我正在 Oracle 中编写存储过程和函数,它们将引用游标返回到 ColdFusion,并且一切正常。但我读到的所有内容都表明,当我完成后,我需要显式关闭游标或引用游标,否则我可能会在以后耗尽句柄。
但是,如果我在函数/存储过程末尾关闭游标,数据不会返回到 ColdFusion。
那么完成后如何关闭引用光标呢?
I'm writing stored procedures and functions in Oracle which return ref cursors to ColdFusion and everything works fine. But everything I've read says that I need to explicitly close a cursor or ref cursor when I'm done with it, else I risk running out of handles later.
But if I close the cursor at the end of the function/stored proc, the data is not returned to ColdFusion.
So how do I close the ref cursor once I'm done with it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
每当数据库连接关闭时,游标也将关闭。在 CF 管理中,您对数据库连接数有限制。如果对传递给 Oracle 的每个值都使用 cfqueryparam,则将允许对同一查询重用同一连接(除非已达到超时)。您必须确保 Oracle 中的游标池限制和 CF admin 中的连接限制一致。听起来这个应用程序从来没有出现过问题,所以情况可能就是这样。
Whenever the database connection is closed, the cursor will also be closed. In the CF admin, you have a limit to the number of database connections. If you use cfqueryparam for every value passed to Oracle, you will allow reuse of the same connection for the same query (unless a timeout has been reached). You have to make sure the cursor pool limit in Oracle and the connection limit in CF admin are in agreement. It sounds like this app has never had a problem, so that is probably the case.
您的 ColdFusion 应用程序将负责关闭返回给它的游标。
我不是 ColdFusion 专家,所以我不完全确定您需要的语法。但是与数据库交互的客户端语言总是具有某种对象或结构来表示您从中获取的结果集。当您完成获取数据后,将会有某种
close
方法来关闭结果集。这也将关闭数据库中的REF CURSOR
。确保您的 ColdFusion 应用程序始终调用 close 方法,即使在获取数据时出现异常 — 游标泄漏的最常见原因是客户端应用程序没有在异常处理程序中关闭游标。Your ColdFusion application will be responsible for closing the cursor that is returned to it.
I'm not a ColdFusion expert so I'm not completely sure about the syntax you'd need. But client languages that interact with databases invariably have some sort of object or structure to represent a result set that you fetch from. When you're done fetching the data, there will be some sort of
close
method that closes the result set. That will also close theREF CURSOR
in the database. Make certain that your ColdFusion application always calls the close method even if there is an exception while you're fetching the data-- the most common cause of cursor leaks is that the client application doesn't close cursors in the exception handler.