在 OLTP 数据库(SQL Server)中使用游标

发布于 2025-01-05 22:38:14 字数 398 浏览 2 评论 0原文

在从网站调用的存储过程中使用游标是否安全?这对性能有明显的影响,但我在这里想提出的是变量@@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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

携君以终年 2025-01-12 22:38:14

除非你使用全局游标,否则你应该安全地

说,为什么你使用游标,几乎所有事情都可以基于 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文