在OLTP数据库(SQL Server)中使用游标 [英] Using cursor in OLTP databases (SQL server)

查看:114
本文介绍了在OLTP数据库(SQL Server)中使用游标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在从网站调用的存储过程中使用游标是否安全?有明显的性能损失,但我想在这里提出的是变量@@ Fetch_status的问题。存储过程中使用的@@ Fetch_status的作用域是一个连接。不可能两个不同的用户通过UI从同一连接调用相同的存储过程?这不会导致意外的结果吗?

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?

换句话说,@@ Fetch_status是全局的,不仅是一个范围,而是整个连接, ?

In other words, would the fact that @@Fetch_status is global not just to a scope but to the entire connection, cause any concerns?

注意:这篇文章不是关于使用游标是否是一个好主意。我会感谢与@@ Fetch_status相关的响应。请在此处讨论专家和

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

推荐答案

除非使用全局游标,否则应该是安全的

Unless you are using global cursors you should be safe

说,为什么你使用游标,几乎一切都可以实现基于sql服务器设置,它会在几乎每一种情况下快很多倍

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

这篇关于在OLTP数据库(SQL Server)中使用游标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆