这种问题真不好意思提出来,呵呵......

jyq686 2004-11-09 05:43:28
在PL/SQL里定义了一个游标,我想更新当前游标所在行的一列数据,这个where字句怎么写来着?
update temp_renyxx set a_xianlcxdm=str_xianlcxdm where current cursor;
这样写有错,请问怎么写?谢谢
...全文
88 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
bluelamb 2004-11-10
  • 打赏
  • 举报
回复
1.定义游标时
cursor cursorname is select * from table for update ;
2.使用游标时
for aaa in cursorname loop
update a set name='sss' where ... current of cursorname
end loop;
jyq686 2004-11-10
  • 打赏
  • 举报
回复
不是有个where current cursor之类的子句吗?我是问这个子句怎么写来着????
kinggom 2004-11-09
  • 打赏
  • 举报
回复
同意楼上的,用fetch打开游标,然后用for循环得到游标值
create or replace procedure p_test_refcur is
v_refcur PKG_RefCursor.Refcursor;
--cursor cur is select * from sys.seq$;
cursor c1 is select * from t_mode for update ;
v_count integer;
begin

--prc_Test_refcursor(v_refcur);
open v_refcur for 'select count(*) from t_pay_mode';

fetch v_refcur into v_count;
dbms_output.put_line(v_count);
--aa;
--open c1;
for v1 in c1 loop
if v1.mode_id=1 then
update t_mode set mode_Name='现在1' where mode_id=v1.mode_id;
--1.mode_name:='现在2';
null;
end if;
end loop;
end p_test_refcur;
lialin 2004-11-09
  • 打赏
  • 举报
回复
create or replace procedure p_test_refcur is
v_refcur PKG_RefCursor.Refcursor;
--cursor cur is select * from sys.seq$;
cursor c1 is select * from t_mode for update ;
v_count integer;
begin

--prc_Test_refcursor(v_refcur);
open v_refcur for 'select count(*) from t_pay_mode';

fetch v_refcur into v_count;
dbms_output.put_line(v_count);
--aa;
--open c1;
for v1 in c1 loop
if v1.mode_id=1 then
update t_mode set mode_Name='现在1' where mode_id=v1.mode_id;
--1.mode_name:='现在2';
null;
end if;
end loop;
end p_test_refcur;


lialin 2004-11-09
  • 打赏
  • 举报
回复
你直接用关键字的条件进行更新不就可以了吗?

17,134

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧