Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: recycling numbers from db
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
![]() |
![]() |