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: Using sequence for default value, help!!

Re: Using sequence for default value, help!!

From: Rafal Jank <yankee_at_wp-sa.pl>
Date: Thu, 26 Apr 2001 11:24:13 +0200
Message-ID: <3AE7E93D.8531D16D@wp-sa.pl>

"Chang, Yu-Hua" wrote:
>
> Hi,
>
> I want to have a serial number to be the primary key in a table.
> I create a sequence successfully,
> but when I use it while creating table, it raise ORA-00984 error.
> My Oracle server infomation is:
> Oracle8 Enterprise Edition Release 8.0.5.0.0 - Production
> PL/SQL Release 8.0.5.0.0 - Production
> Can anyone tell me what's wrong with my SQL code:
>
> SQL> create sequence id_test_id
> 2 minvalue 1
> 3 maxvalue 999
> 4 increment by 1
> 5 start with 1
> 6 nocycle
> 7 nocache
> 8 noorder;
>
> §Ç¦C¤w³Q«Ø¥ß
>
> SQL> create table id_test(
> 2 id number(3) default id_test_id.nextval,
> 3 tday date default sysdate,
> 4 constraint id_test_pk primary key (id)
> 5 );
> id number(3) default id_test_id.nextval,
> *

You can't do it like this. You must create trigger which will be setting id value.

-- 
_/        _/  _/_/_/  -----     Rafa³ Jank yankee_at_wp.pl     -----
 _/  _/  _/  _/   _/         Wirtualna Polska SA   http://www.wp.pl 
  _/_/_/_/  _/_/_/    ul. Uphagena 2, 80-237 Gdansk, tel/fax. (58) 5215625
   _/  _/  _/         --------==*  http://szukaj.wp.pl *==----------
Received on Thu Apr 26 2001 - 04:24:13 CDT

Original text of this message

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