RE: Creating table with a sequence as a Primary Key.....

From: (wrong string) ñir <laucanir_at_hotmail.com>
Date: 2000/06/29
Message-ID: <395ba069_at_dnewserver.firstcom.cl>#1/1


  • Sequence CREATE SEQUENCE YourSequence MINVALUE 1 NOMAXVALUE;
  • Trigger CREATE OR REPLACE TRIGGER YourTable_T BEFORE INSERT ON YourTable FOR EACH ROW DECLARE NextVal INTEGER;

BEGIN
 /* Get & Assign */
 SELECT YourSequence.NextVal INTO NextVal FROM Dual;  :NEW.ENTRY_NUMBER := NextVal;
END;
/

  • Where YourTable : Your Table Name.
  • YourSequence : Your Sequence Name.

HTH,
Luis Aucañir H.

Newbie (Joe ) <jranseth_at_hotmail.com> escribió en el mensaje de noticias GrL65.215$Hs3.3694_at_news1.mts.net...
> Hello again,
> I need to create a table that has a sequence in it as the primary
> key.....I have no idea how, as I am new to Oracle (8i), and databases
> altogether (VB programmer).
> I heard that I have to create a database trigger...is this correct?
 How
> do I do that?
> The table will be something like the following...
>
> ENTRY_NUMBER Sequence, PK
> STATE_CODE Varchar2, FK (references state table)
> PRODUCT_CODE Varchar2, FK (references product table)
> ENTRY_OWNER Varchar2
> DATE_ENTERED Date (format DD-MON-YY hh:mi:ss am)
> ......other entry details, etc.
>
> Could I please get some help in creating this table? Sample SQL or
 detailed
> answers would be greatly appreciated as I am not really a database guru.
> Thank you so much for anyhelp...
>
>
>
>
Received on Thu Jun 29 2000 - 00:00:00 CEST

Original text of this message