四个值
ROW 1 X1
ROW 2 X2
ROW 3 X3
ROW 4 X4
如何依次取 X1到X4?循环取就行
------解决方案--------------------
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;
/