for cur1 in (select * from tt for update) loop update tt set id=id*2 where id=cur1.id; end loop;
更新当前记录用current of 举个例子 declare cursor a is select * from tt for update; begin for cur1 in a loop update tt set id=id+1 where current of a; end loop; end;更新游标的当前记录
要更新某个记录的值,可以加个判断 declare cursor a is select * from tt for update; --定义游标 begin for cur1 in a loop --游标循环 if cur1.id=2 then update tt set id=id+1 where current of a;--更新当前记录 end if; end loop; end;
怎么commit 能不能具体点
declare cursor a is select * from tt for update; --定义游标 begin for cur1 in a loop --游标循环 if cur1.id=2 then update tt set id=id+1 where current of a;--更新当前记录 end if; end loop; end;
for cur1 in a loop --游标循环 if cur1.id=2 then update tt set id=id+1 where current of a;--更新当前记录 end if; end loop;循环结束后加上commit;
update tt set id=id*2 where id=cur1.id;
end loop;
更新当前记录用current of
举个例子
declare
cursor a is select * from tt for update;
begin
for cur1 in a loop
update tt set id=id+1 where current of a;
end loop;
end;更新游标的当前记录
declare
cursor a is select * from tt for update; --定义游标
begin
for cur1 in a loop --游标循环
if cur1.id=2 then
update tt set id=id+1 where current of a;--更新当前记录
end if;
end loop;
end;
cursor a is select * from tt for update; --定义游标
begin
for cur1 in a loop --游标循环
if cur1.id=2 then
update tt set id=id+1 where current of a;--更新当前记录
end if;
end loop;
end;
for cur1 in a loop --游标循环
if cur1.id=2 then
update tt set id=id+1 where current of a;--更新当前记录
end if;
end loop;循环结束后加上commit;
其实我要做这样一个存储过程,以游标作为返回类型。
这个游标是个多表连接,如果是这样的话,update后面的表名字怎么写?
菜鸟,别见怪!