那下边的语句会产生等待么: declare v1 number(1); v2 number(1); nid number; cursor cur as select select id,a1,a2 from a; begin open cur loop fatch cur into nid,v1,v2; exit when cur %notfound; if v1>v2 then update a set a3=v1 where id=nid; els update a set a3=v2 where id=nid; end if; end loop; end
如果用下边的语句会产生等待么: declare v1 number(1); v2 number(1); nid number; cursor cur as select select id,a1,a2,a3 from a; begin open cur loop fatch cur into nid,v1,v2; exit when cur %notfound; if v1>v2 then cur.a3=v1;--?不知道语句是否正确,请指教 els cur.a3=v2;--?不知道语句是否正确,请指教 end if; end loop; end
if v1>v2 then cur.a3=v1;--?不知道语句是否正确,请指教 els cur.a3=v2;--?不知道语句是否正确,请指教 end if;有这种写法吗? Oracle里不这样写,只能重游标里读取值。
另外好像是for update选项就是打开一个可更新游标,但具体语句如何写,
不知道,
declare
v1 number(1);
v2 number(1);
nid number;
cursor cur as select select id,a1,a2 from a;
begin
open cur
loop
fatch cur into nid,v1,v2;
exit when cur %notfound;
if v1>v2 then
update a set a3=v1 where id=nid;
els
update a set a3=v2 where id=nid;
end if;
end loop;
end
declare
v1 number(1);
v2 number(1);
nid number;
cursor cur as select select id,a1,a2,a3 from a;
begin
open cur
loop
fatch cur into nid,v1,v2;
exit when cur %notfound;
if v1>v2 then
cur.a3=v1;--?不知道语句是否正确,请指教
els
cur.a3=v2;--?不知道语句是否正确,请指教
end if;
end loop;
end
cur.a3=v1;--?不知道语句是否正确,请指教
els
cur.a3=v2;--?不知道语句是否正确,请指教
end if;有这种写法吗?
Oracle里不这样写,只能重游标里读取值。