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

Home -> Community -> Usenet -> c.d.o.tools -> Re: automatic attribute insert

Re: automatic attribute insert

From: <xmark.powell_at_eds.com.x>
Date: 19 Apr 2001 14:18:08 GMT
Message-ID: <9bms30$o2b$1@news.netmar.com>

In article <9bmgne$2q0si$1_at_reader03.wxs.nl>, Loki <rinze_cats_at_hotmail.com> writes:
>Hiya, I maintain a logtable where the primary key should be a system
>generated (sequential) number.
>
>How do I tell oracle8 to automatically insert this value?
>
>many thanx
>rinze
>

See the SQL Manual and look up create sequence. To use the sequence you have two choices. First you can code the sequence in the insert statement as in insert into x (key, col2) values (sequence_name.nextval,'TWO');

Or you can place a before insert trigger on the table and do something like v_key number;
begin
select sequence_name.nextval into v_key from dual; :new.key := v_key;
end;

Received on Thu Apr 19 2001 - 09:18:08 CDT

Original text of this message

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