日期:2014-05-17 浏览次数:20864 次
drop table x;
create table x (xx varchar2(10));
insert into x values('X1');
insert into x values('X2');
insert into x values('X3');
insert into x values('X4');
create table x_cnt (cnt number);
insert into x_cnt values(1);
commit;
/
create or replace procedure get_x(o out varchar2) is
v_cnt number;
v_max number;
begin
select cnt into v_cnt from x_cnt;
select count(1) into v_max from x;
select xx into o from (select xx, rownum rn from x) where rn = v_cnt;
if (v_cnt = v_max) then
v_cnt := 0;
end if;
v_cnt := v_cnt + 1;
update x_cnt set cnt = v_cnt;
commit;
end;
/