Re: lowest free number
From: Sanjay D. S. <sanjay_at_fsg.prusec.com>
Date: 1996/06/24
Message-ID: <31CEB890.41C6_at_fsg.prusec.com>#1/1
Date: 1996/06/24
Message-ID: <31CEB890.41C6_at_fsg.prusec.com>#1/1
Michael Daehling wrote:
>
> Hi,
>
> I want to get the lowest free number of a column. The column is a continuous
> number and the primary key of the table. I want to recycle the old numbers
> after delete.
> I think a PL/SQL-function can do this - or is there a simple solution?
>
> Thanks in advance
>
> Michael Daehling
> --
>
How about this query:
select min(key_col) + 1
from tab a
where not exists (select 'x'
from tab b where b.key_col = a.key_col + 1);
HTH
Sanjay D. S.
(Oracle Consultant)
Prudential Securities, Inc.
Received on Mon Jun 24 1996 - 00:00:00 CEST