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

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Sequence as column default

Re: Sequence as column default

From: Alan Davey <adavey_at_competitrack.com>
Date: Mon, 10 Mar 2003 13:15:55 -0800
Message-ID: <F001.005652E3.20030310131555@fatcity.com>


You could also do it as part of your insert statement if you didn't want to use a trigger.

INSERT INTO employees

   VALUES (employees_seq.nextval, 'John', 'Doe', 'jdoe',    '555-1212', TO_DATE(SYSDATE), 'PU_CLERK', 2500, null, null,    30);

Same thing goes with currval also.

-- 

Alan Davey
adavey_at_competitrack.com
718-482-4200 x106


On 3/10/2003 3:49 PM, DENNIS WILLIAMS <DWILLIAMS_at_LIFETOUCH.COM> wrote:

>Has anyone defined a sequence as the default value for a column? The
>manual
>is a little ambiguous (in my mind anyway):
>
>In the 8.1.7 manual:
>Restriction: A DEFAULT expression cannot contain references to other
>columns, the pseudocolumns CURRVAL, NEXTVAL, LEVEL, and ROWNUM, or
>date
>constants that are not fully specified.
>
>In 9i this was altered to read:
>Restriction on Default Column Values
>A DEFAULT expression cannot contain references to PL/SQL functions
>or to
>other columns, the pseudocolumns LEVEL, PRIOR, and ROWNUM, or date
>constants
>that are not fully specified.
>
>SQL> alter table test add
> 2 (col3 number default addressID.NextVal);
>(col3 number default addressID.NextVal)
> *
>ERROR at line 2:
>ORA-00984: column not allowed here
>
>The alternative is to use an insert trigger, but it seems this would
>be more
>efficient. Since we are planning to use this a LOT, I thought I should
>try
>for a definate answer. Thanks for your patience.
>
>Dennis Williams
>DBA, 40%OCP, 100% DBA
>Lifetouch, Inc.
>dwilliams_at_lifetouch.com
>--
>Please see the official ORACLE-L FAQ: http://www.orafaq.net
>--
>Author: DENNIS WILLIAMS
> INET: DWILLIAMS_at_LIFETOUCH.COM
>
>Fat City Network Services -- 858-538-5051 http://www.fatcity.com
>San Diego, California -- Mailing list and web hosting services
>---------------------------------------------------------------------
>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).
>
>
>
-- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Alan Davey INET: adavey_at_competitrack.com Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- 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 Mar 10 2003 - 15:15:55 CST

Original text of this message

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