利用游标编写一个匿名PL/SQL块,用以完成对emp表中的工资小于3000的记录进行删除。
展开全部
--一句话的方法
delete from emp where 工资<3000;
--匿名块的方法
declare
type refcursor is ref cursor;
dealinfo refcursor;
begin
open dealinfo for
select id,工资
from emp;
loop
fetch dealinfo into v_id,v_工资;
exit when dealinfo%notfound;
if v_工资<3000 then
delete from emp where id=v_id;
end if;
end loop;
close dealinfo;
end;
delete from emp where 工资<3000;
--匿名块的方法
declare
type refcursor is ref cursor;
dealinfo refcursor;
begin
open dealinfo for
select id,工资
from emp;
loop
fetch dealinfo into v_id,v_工资;
exit when dealinfo%notfound;
if v_工资<3000 then
delete from emp where id=v_id;
end if;
end loop;
close dealinfo;
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询