Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: sequence of numbers
select MIN(a.mt1)+1 INTO XY FROM
(select mt1 FROM MT MINUS SELECT mt1-1 FROM MT) a;
is better, but still full scan ...
JP
On Mon 19. November 2001 12:40, you wrote:
> Hello,
> I've a table mt ( mt1 NUMBER(10) NOT NULL ) with unique index on the mt1
> column.
> There's a sequence of numbers 1,2,3,4,6,7,8,10,11 ... in the mt1
>
> Now, I want to get the smallest number which is not in mt1
> (excluding min(mt1)-x of course) into XY (in my example is it n. 5).
>
> When I use SELECT MIN(mt1)-1 INTO XY FROM MT WHERE MT1 NOT IN (select
> mt1+1 from mt)
> my perfromance goes pretty down :-))) (there's about 5 mil. of numbers).
>
> Some idea how to get it without cursor?
>
> Thanks (and sorry it's monday)
> JP
-- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Jan Pruner INET: jan_at_pruner.cz Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Mon Nov 19 2001 - 07:19:18 CST
![]() |
![]() |