Re: Default sequence number

From: Le-Chin Eugene Liu <philt_at_u.washington.edu>
Date: 1996/11/07
Message-ID: <55t4el$4mn_at_nntp1.u.washington.edu>#1/1


Well, the following can save you a few lines.

   SLECT company_seq.NEXTVAL INTO :NEW.company FROM DUAL; but you still need to speciify the column list when insert as the reply suggested below.

In article <554dos$hoi_at_o.online.no>,
Alf-Kenneth Aabel <alf-ka_at_online.no> wrote:
>With this trigger I can insert into company. Primary key in company is
>company.
>
>-- Trigger for company
>CREATE OR REPLACE TRIGGER tibr_company
>BEFORE INSERT ON company
>FOR EACH ROW
>DECLARE
> nVal company.company%TYPE;
>BEGIN
> SELECT seq_company.NEXTVAL INTO nVal FROM DUAL;
> :new.company := nVal;
>END;
>/
>
>
>lesliet_at_u.washington.edu (L. Tseng) wrote:
>
>>But, even with the trigger, it still requires to specify the column list
>>when doing the insert.
>> INSERT INTO tablename VALUES (val2,val3,val4) won't work when
>> tablename has (col1,col2,col3,col4) and col1 is the ID column.
 

>>Do you know why Oracle can't use NEXTVAL as default
>>when creating a table?
 

>> CREATE TABLE tablename (
>> ID number DEFAULT seq_num.NEXTVAL)
>
>
>
Received on Thu Nov 07 1996 - 00:00:00 CET

Original text of this message