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: Newbie: Primary key assignment

Re: Newbie: Primary key assignment

From: Steve McDaniels <steve.mcdaniels_at_sierra.com>
Date: 2000/02/14
Message-ID: <889ttb$l6f$1@plo.sierra.com>#1/1

First, decide to let the database create the primary key VALUE (works in multi-user envirionments)

create table a_table
(my_key_field, other_fields...)

alter table a_table add constraint primary key (my_key_field) using index tablespace my_index_tablespace_name storage (my storage parameters)

create sequence my_primary_key_sequence_name;

create trigger my_primary_key_trigger_name before insert on a_table
begin
  select my_primary_key_sequence_name.NEXTVAL into :my_key_field from dual; end;

insert into a_table values (NULL, some_data, some_more_data, ...);

"SKurosky" <skurosky_at_aol.com> wrote in message news:20000211135307.01535.00000620_at_ng-fp1.aol.com...
> >STEPHAN WROTE:
 
> >I am using Forms 5 and Oracle7.
> >
> >I wonder where I should handle the "primary key" assignment for my
 tables,
> >in the server (database insert row trigger) OR in my forms (pre-insert
> >trigger) ?
> >
> >What happens when both triggers exist?
> >
> >Thanks
> >Stephan
> >
> >
> >Stephan
> What do you mean by "handle". Have you created a sequence to generate your
> primary keys. The primary key should be identified at table creation with
 the
> primary key constraint, or with an alter table..? Can you be a little more
> specific?
> Sandy
>
> >
> >
> >
> >
> >
> >
> >
> >
>
>
Received on Mon Feb 14 2000 - 00:00:00 CST

Original text of this message

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