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 [EMAIL PROTECTED] 718-482-4200 x106 On 3/10/2003 3:49 PM, DENNIS WILLIAMS <[EMAIL PROTECTED]> 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. >[EMAIL PROTECTED] >-- >Please see the official ORACLE-L FAQ: http://www.orafaq.net >-- >Author: DENNIS WILLIAMS > INET: [EMAIL PROTECTED] > >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: [EMAIL PROTECTED] (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: [EMAIL PROTECTED] 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: [EMAIL PROTECTED] (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).
