方案,其中使用游标是唯一的解决方案 [英] Scenario where using cursor is the only solution

查看:93
本文介绍了方案,其中使用游标是唯一的解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在使用游标是唯一解决方案的情况,并且我们无法将其替换为"While循环",临时表等其他任何选项?

Is there any scenario exists where using cursor is the only solution and we can''t replace it with any other options like "While loop", temp table etc.?

推荐答案

答案是动态游标.如果我们使用表变量或临时表,则它将包含插入表变量或临时表时的最后提交的数据.因此,您将不会在基表中获得修改的记录或新插入的记录.
尽管动态游标为您提供了一个选择,如果有任何更新或插入到基表中,则更改将得到反映.
The answer is Dynamic cursor. If we use Table variable or Temp table then it will contains the last committed data at the time of insertion into table variable or temp table. So you will not get the modified records or newly inserted records happened in base table.
While dynamic cursor gives you an option if there is any updates or insertion into base table then the changes will get reflected.


我不这么认为.我们可以使用表变量或临时表代替游标,并对其执行完全相同的操作.
I don''t think so. We can use Table Variable or Temp Table instead of cursor and do the exactly same things with them.


如果DBA限制了查询/存储过程的大小
If a DBA limits the size of queries / stored procedures


这篇关于方案,其中使用游标是唯一的解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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