Absolutly reasonable. Moreover this is the only way to avoid sequence
gaps which might arise due to sequence numbers caching.
regards,
M. Armaghan Saqib
- SQL PlusPlus : Add power to SQL Plus command line
- SQL Link for XL : Integrate Oracle with XL
- Oracle CBT with sample GL (Triggers and Forms Source Code included.
Download free: http://www.geocities.com/armaghan/
John Shaft <shaft_at_meanmutha.com> wrote in message
news:Pine.LNX.4.10.9912172103260.30070-
100000_at_alfred.laffeycomputer.com...
> In response to my question about how to increment a Primary key with
each
> new INSERT so that I get an automatic unique value:
>
> On Fri, 17 Dec 1999, Steve McDaniels wrote:
>
> > 1. create a sequence
> > 2. create table
> > 3. create trigger for insert on this table
> > which uses the sequence's nextval to
> > populate your primary key field.
>
>
>
> If I'm looking for a way to do this that is more portable. Sequences
> are not real portable, right? (to other RDBMS)
>
> Would it be possible to achieve my end like this:
>
> Creating another table to hold the latest primary key value
> Use a Transaction to select the current value and then insert the new
data
> with the incremented value (and update the key value table).
> Finally, commit this as one atomic operation.
>
> Does that sound reasonable?
>
> Any thoughts? I am after portability over pure efficiency. I am used
to
> dealing with MySQL, which is not as full-featured as Oracle (but is
fast
> as hell and reall cheap). MySQL has an AUTO_INCREMENT feature that
can be
> assigned to a column. It probably has this because it lacks
transactions
> and sequences.
>
> Thanks,
>
> shaft_at_meanmutha.com
> http://www.meanmutha.com
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Sat Dec 18 1999 - 06:41:21 CST