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: Marco Klooster <kloostr_at_boekhuis.nl>
Date: 2000/05/11
Message-ID: <8fcn1r$djt$1@porthos.nl.uu.net>#1/1

I think this will work:

create table tab1 (col1 number);

insert into tab1 values(1);
insert into tab1 values(3);
insert into tab1 values(4);

select * from tab1;

      COL1


         1
         3
         4

insert into tab1
select min(col1) + 1
from tab1 a
where not exists (select 1 from tab1 b
where a.col1 + 1 = b.col1);

select * from tab1;
More...

      COL1


         1
         3
         4
         2


"Dominick Vansevenant" <dominick.vansevenant_at_mobyus.com> schreef in bericht news:39197abb$0$11459_at_bru5-newsr1.be.uu.net...
> 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
>
>
>
>
Received on Thu May 11 2000 - 00:00:00 CDT

Original text of this message

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