什么是光标进入sql server以及游标对我们的querry有什么用? [英] what is cursor into sql server and what is the use of cursor into our querry ?

查看:84
本文介绍了什么是光标进入sql server以及游标对我们的querry有什么用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

光标到sql server是什么用光标到我们的querry有什么用?



更新:来自评论:

< br $> b $ b

 + ---- + ---------- + ----- + ---- ------- + ---------- + 
| ID | NAME |年龄|地址| SALARY |
+ ---- + ---------- + ----- + ----------- + ---------- +
| 1 |拉梅什| 32 |艾哈迈达巴德| 2000.00 |
| 2 | Khilan | 25 |德里| 1500.00 |
| 3 | kaushik | 23 |哥打| 2000.00 |
| 4 | Chaitali | 25 |孟买| 6500.00 |
| 5 |哈迪克| 27 |博帕尔| 8500.00 |
| 6 | Komal | 22 | MP | 4500.00 |
+ ---- + ---------- + ----- + ----------- + ---------- +





  DECLARE  
total_rows number( 2 );
BEGIN
更新客户
SET 薪水=薪水+ 500 ;
IF sql%notfound 那么
dbms_output.put_line(' 没有客户选择');
ELSIF sql%found THEN
total_rows:= sql%rowcount;
dbms_output.put_line(total_rows || ' 客户选择');
END IF ;
END ;







表数据和查询上面给出但我不明白光标的使用和使用光标的目的请在这里看到并解释为简单的话我对光标很新。



谢谢

/

解决方案

这是一个为每个执行的循环选择的行。如果您需要执行无法在数据集上运行的复杂函数,这非常有用。



至于如何在查询中使用它?我不知道。我既看不到你的显示器,也看不懂你的想法。抱歉我缺乏能力:P



希望有所帮助^ _ ^

Andy



更新:

啊,Oracle。你没告诉我> _<



这不是游标。在这种情况下,它只是一个单独的更新语句,然后将输出抛出到实体框架,让您知道是否找到了客户



此链接恰好谈论返回消息和游标:



​​ http:// stackoverflow.com/questions/13075538/pl-sql-notfound [ ^ ]

what is cursor into sql server and what is the use of cursor into our querry ?

UPDATE: from comments:


+----+----------+-----+-----------+----------+
| ID | NAME | AGE | ADDRESS | SALARY |
+----+----------+-----+-----------+----------+
| 1 | Ramesh | 32 | Ahmedabad | 2000.00 |
| 2 | Khilan | 25 | Delhi | 1500.00 |
| 3 | kaushik | 23 | Kota | 2000.00 |
| 4 | Chaitali | 25 | Mumbai | 6500.00 |
| 5 | Hardik | 27 | Bhopal | 8500.00 |
| 6 | Komal | 22 | MP | 4500.00 |
+----+----------+-----+-----------+----------+



DECLARE 
total_rows number(2);
BEGIN
  UPDATE customers
  SET salary = salary + 500;
  IF sql%notfound THEN
    dbms_output.put_line('no customers selected');
  ELSIF sql%found THEN
    total_rows := sql%rowcount;
    dbms_output.put_line( total_rows || ' customers selected ');
  END IF; 
END;




table data and query is given above but i dont understand the use of cursor and the purpose of using cursor here please see this and explain this into simple words i am very new to cursor .

thanks
/

解决方案

It's a loop that executes for each row of the select. This is useful if you need to perform complex functions that cannot be run on a dataset.

As for how it is used in your query? I don't know. I can neither see your monitor nor read your mind. Sorry for my lack of ability :P

Hope that helps ^_^
Andy

UPDATE:
Ah, Oracle. You didn't tell me that >_<

This is not a cursor. In this case it is just a single update statement then throws an output to the entity framework letting you know if the customer was found or not

This link happens to talk about the return message AND cursors:

http://stackoverflow.com/questions/13075538/pl-sql-notfound[^]


这篇关于什么是光标进入sql server以及游标对我们的querry有什么用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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