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

Home -> Community -> Usenet -> c.d.o.server -> Re: Default column value of MAX +1 of column - possible in Oracle 9i?

Re: Default column value of MAX +1 of column - possible in Oracle 9i?

From: Galen Boyer <galenboyer_at_hotpop.com>
Date: 24 Mar 2005 16:33:05 -0600
Message-ID: <upsxocwn2.fsf@hotpop.com>


On Thu, 24 Mar 2005, Kenneth Koenraadt wrote:

> On 24 Mar 2005 08:04:51 -0800, usenet_at_fitzg.com (David FitzGerald)
> wrote:
> 

>>Hello -
>>
>>I'm trying to do something which I think ought to be simple, but am
>>finding hard!
>>
>>I have a table which I want the default value of the "ID" column to be
>>"MAX(ID)+1" - I can't get this to work. Is this possible to do, or am
>>I barking up the wrong tree? The reason I need to do this is that an
>>application needs to add to this table, but will not be able to do a
>>"select MAX(ID)+1 from emp" before it inserts the new row. It also
>>can't do a subselect in its insert. A PITA!
>>
>>I have thought about using a sequence instead, but this would require
>>changing application code which I am reluctant to do.
>>
>>Is it at all possible to have a default value as I outline above?
>>
>>Any help or pointers you can give would be greatly appreciated!
>>
>>David.
> 
> Use sequences. In that I agree with the other responders. But *don't
> use triggers unless you really have to*. Change your application code
> instead.
> 
> Triggers are evil. They don't scale well and they make application
> changes more awkward, time-consuming and expensive.

How so?

-- 
Galen deForest Boyer
Received on Thu Mar 24 2005 - 16:33:05 CST

Original text of this message

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