pl/sql游标
2022-12-20 本文已影响0人
Jianbaozi
image.png
declare
ie_id NUMBER(10);
ie_fn varchar2(20);
ie_ln varchar2(20);
ie_ge char(1);
cursor ie_cur is select ID,FIRST_NAME,LAST_NAME,GENDER from it_employees;
begin
open ie_cur;
fetch ie_cur into ie_id,ie_fn,ie_ln,ie_ge;
loop
exit when not ie_cur%found;
if ie_ge='1' then insert into it_employees_m(id,first_name,last_name,gender) values(ie_id,ie_fn,ie_ln,ie_ge);
else
insert into it_employees_f(id,first_name,last_name,gender) values(ie_id,ie_fn,ie_ln,ie_ge);
end if;
fetch ie_cur into ie_id,ie_fn,ie_ln,ie_ge;
end loop;
close ie_cur;
end;