Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: recycling numbers from db
Dominick Vansevenant wrote:
> Hello,
>
> I have to get a value that is not in a table, how can I do this?
> The purpose is to recycle numbers, e.g.:
>
> table content:
>
> 1
> 3
> 4
> 5
> 7
> 9
> 10
>
> I want the first number that is not in, thus I want 2 as result.
> Is this possible?
>
> Thanks in advance,
>
> Dominick
What I'd do is scan the ordered table for each value in turn, on the
first
no-data-found I'd use that number next - you can
scan in numerical sequence - right?
for unused_value in 1..limit loop
begin
select val from table where val = unused_value; exception
when no_data_found then exit;
end;
end loop;
insert into blah values(unused_value);
HTH Received on Wed May 10 2000 - 00:00:00 CDT
![]() |
![]() |