declare v_id number; v_value VARCHAR2(10); v_count NUMBER; begin SELECT max(id) into v_count from test1; begin while v_count>0 loop v_count := count-1; dbms_output.put_line(v_count); select id,value into v_id,v_value from test1 where id := v_count; dbms_output.put_line(v_id); dbms_output.put_line(v_value); end loop; end; end;