可以更新光标吗? [英] Can a Cursor be updated?

查看:66
本文介绍了可以更新光标吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以更改循环上光标的内容吗?



赞:



< pre lang =SQL> DECLARE
光标 c;
id int ;
BEGIN
LOOP
- 使用类似的查询初始化游标,但是使用id变量的位置不正确。
- 光标循环处理数据
END LOOP
END ;

解决方案

尝试使用WHERE CURRENT OF,请看这里的例子:



http://www.techonthenet.com/oracle/cursors/current_of.php [ ^ ]


我正在考虑改变光标,而不是使用光标的表。

我得到了这个解决方案:



  DECLARE  
id int;
BEGIN
LOOP
- id = new_value;
FOR X IN < span class =code-leadattribute>(SELECT
* FROM T WHERE T ID = ID)
LOOP
- 流程 数据
END LOOP;
END LOOP;
END;


Can i change the content of a cursor on a loop?

Like:

DECLARE
 Cursor c;
 id int;
BEGIN
LOOP
    --Initialize cursor with similar query but distict where using the id variable.
    --Cursor loop to process data
END LOOP
END;

解决方案

Try using WHERE CURRENT OF, please see the example here:

http://www.techonthenet.com/oracle/cursors/current_of.php[^]


I was thinking about change the cursor, not the table using cursor.
I got this solution:

DECLARE
 id int;
BEGIN
LOOP
    -- id = new_value;
    FOR X IN (SELECT * FROM T WHERE T.ID = ID)
    LOOP
         -- Process data.
    END LOOP;
END LOOP;
END;


这篇关于可以更新光标吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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