Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Server Maintained Unique Index
A copy of this was sent to "Simon Miles" <simon.miles_at_no.bigfoot.spam.com>
(if that email address didn't require changing)
On Mon, 1 Nov 1999 11:39:36 -0000, you wrote:
>First of all please excuse my ignorance for what I believe is a trivial
>Oracle problem but I scanned several sources without much luck...
>
>I have an application currently running on MS SQL Server that has several
>tables with an IDENTITY column. The column is a server maintained, unique
>identifier on the table.
>
>I would like to create the same functionality in Oracle but am unsure of the
>required syntax. So far I have got as far as creating a sequence but wasn't
>sure how to script the trigger.
>
>BTW. I only need a unique column on the table for integrity reasons. I
>want the column to be looked after by the server and don't actually care
>what the values are.
>
>Could anyone please help (especially if there is an easier way of doing
>this!!!)
>
>Simon.
>
>
>
>
create sequence my_seq; -- only need one of these / database if you want.
create or replace trigger my_trigger -- one of these / table...
before insert on my_table for each row
begin
select my_seq.nextval into :new.my_key_column from dual;
end;
/
--
See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'...
Current article is "Part I of V, Autonomous Transactions" updated June 21'st
Thomas Kyte tkyte_at_us.oracle.com Oracle Service Industries Reston, VA USA
Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Mon Nov 01 1999 - 07:53:15 CST