在 OLTP 数据库(SQL Server)中使用游标
在从网站调用的存储过程中使用游标是否安全?这对性能有明显的影响,但我在这里想提出的是变量@@Fetch_status 的问题。存储过程中使用的@@Fetch_status 的范围是一个连接。两个不同的用户是否有可能从同一个连接通过 UI 调用同一个存储过程?这不会带来意想不到的结果吗?
换句话说,@@Fetch_status 不仅对于某个范围而且对于整个连接都是全局的,这一事实是否会引起任何担忧?
注意:这篇文章并不是关于使用光标是否是一个好主意。我希望得到与 @@Fetch_status 相关的回复。请来到这里讨论优点和缺点游标的缺点
Is it safe to use cursors in stored procs that are called from a website? There is the obvious performance hit, but what I am trying to raise here is the issue with the variable @@Fetch_status. The scope of @@Fetch_status used in stored proc, is a connection. Isn't it possible that two different users call the same stored proc, from the same connection, thru the UI? Wouldn't that cause unexpected results?
In other words, would the fact that @@Fetch_status is global not just to a scope but to the entire connection, cause any concerns?
NOTE: This post is not about whether using a cursor is a good idea. I'd appreciate responses relevant to @@Fetch_status. Please come here to discuss the pros and cons of cursors
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除非你使用全局游标,否则你应该安全地
说,为什么你使用游标,几乎所有事情都可以基于 sql server 完成,并且在几乎每种情况下都会快很多倍
Unless you are using global cursors you should be safe
that said, why are you using cursors, almost everything can be accomplished set based in sql server and it will be many times faster in almost every situation