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

Home -> Community -> Usenet -> c.d.o.misc -> How to Query Min PK Value NOT in Table

How to Query Min PK Value NOT in Table

From: simon <simon_at_simon.com>
Date: Wed, 22 Jun 2005 18:56:20 +0800
Message-ID: <42b943d2_1@rain.i-cable.com>


I have a table with primary key values:

1, 2, 6, 8, 10, 13, 15,...

Suppose I need to insert a new row with the minimum PK not used (here it is 3).

Qn 1) What query should I use to get this min value? Assuming a single user environment.

Qn 2) How could I handle the same query in multi-user environment where >1 users may simultaneously get the minimum PK available is 3 and all try to insert 3? (recall that in Oracle reader never get blocked by writer, so simple locking mechanism doesnt prevent >1 users reading the value 3) Received on Wed Jun 22 2005 - 05:56:20 CDT

Original text of this message

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