Re: find max id for forms

From: Connor McDonald <connor_mcdonald_at_yahoo.com>
Date: Tue, 07 Aug 2001 18:56:14 +0100
Message-ID: <3B702BBE.352C_at_yahoo.com>


Matt B. wrote:
>
> "CupOfWater" <asiandoof_at_hotmail.com> wrote in message
> news:e0c9495d.0108060846.33dad8b_at_posting.google.com...
> > Hi, I have a form that has a field, mid denoting membership ids. This
> > corresponds to an ORACLE table that has mid, name, etc. Instead of
> > having the users find the highest mid from the database and enter the
> > next highest one, I want the form to automatically find the largest
> > mid and add 1 to that number and put the result into the mid field. I
> > don't know how to do this, but I think it involves some triggering of
> > some sort and PL/SQL, but I don't know which trigger(s) would be
> > appropriate. Thanks.
> >
> > Kevin
>
> Just write a cursor to get it and then populate your form with it.
>
> SELECT max(mid) + 1
> from <table>
> where <key values>;
>
> Put it in whatever trigger you want to.
>
> -Matt

[Quoted] [Quoted] This only works in a single-user system, since two or more people could [Quoted] get the same value. A sequence is a better solution, or if you must use the (x+1) method, then you need to:

  • lock appropriate rows in table
  • get max(blah)+1
  • release lock

hth
connor

-- 
==============================
Connor McDonald

http://www.oracledba.co.uk

"Some days you're the pigeon, some days you're the statue..."
Received on Tue Aug 07 2001 - 19:56:14 CEST

Original text of this message