create or replace procedure pro_compare() as begin for c1 in(select a from table order by a) loop if (c1.a 与 比较值 的表达式) then --操作 end if; end loop; end;
同意楼上的说法,举个例子说明你的问题吧,以游标做例子: cursor c_TABLE is select a.字段名 from tablename a where 条件……; begin …… for rec_TABLE in c_TABLE loop begin “字段a的值拿去和另外一个数据做比较”代码区; exception when others then rollback; end; end loop; end;大概就是这个样子吧,具体的还得你自己去写。
begin
for c1 in(select a from table order by a) loop
if (c1.a 与 比较值 的表达式) then
--操作
end if;
end loop;
end;
select a.字段名
from tablename a
where 条件……;
begin
……
for rec_TABLE in c_TABLE loop
begin
“字段a的值拿去和另外一个数据做比较”代码区;
exception
when others then
rollback;
end;
end loop;
end;大概就是这个样子吧,具体的还得你自己去写。