Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: recycling numbers from db

Re: recycling numbers from db

From: Job <Job_at_pestilence.net>
Date: 2000/05/10
Message-ID: <39197F77.5DFD69C1@pestilence.net>#1/1

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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US