Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to imitate autovalues ?
A copy of this was sent to Thorsten Buchheim <buchheim_at_ls7.uni.dortmund.de>
(if that email address didn't require changing)
On Thu, 07 May 1998 16:59:47 +0200, you wrote:
>Hello all,
>
>
>I am looking for a way to realze the following :
>
>I need a table, consisting of some columns including one to store
>sequential numbers (for later foreign-key-purposes).
>
>The problem is that I don't want to mention explicitly the
>sequential-number-column in an insert-statement, but simply :
>
>insert(col2,...,coln) values (val2,..,valn) into TABLE
>
>with ORACLE doing the rest by transforming this into
>
>insert(count_col1,...,coln) values (SEQ.nextval,val2,...,valn) into
>TABLE.
>
>Unfortunately I´m a newbie in ORACLE (guessed it?) and presumably
>this can be done by a TRIGGER. If I only knew how....
>It would be nice if you could give me with some hints how to do it.
>
create sequence myseq;
create trigger mytrigger
before insert on T
for each row
begin
select myseq.nextval into :new.col1;
end;
/
>
>Thanks for any help
>
>Thorsten
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA
http://govt.us.oracle.com/ -- downloadable utilities
Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Thu May 07 1998 - 10:15:24 CDT
![]() |
![]() |