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

Home -> Community -> Usenet -> c.d.o.server -> Re: primary keys

Re: primary keys

From: Pawe³ <pp_at_inwar.com.pl>
Date: 1997/06/11
Message-ID: <01bc7660$c3306d00$7179b5c2@PP.system.inwar.com.pl>#1/1

 Hello everyone

Aldo Alejandro <aalejan_at_pacbell.net> napisa³(a) w artykule <01bc743a$da8362a0$cf05aace_at_aalejan.pacbell.net>...
> Hello everyone,
>
> How would you create primary keys in personal oracle 7.3 using the create
> sequence route?
> Also I would like my pk's to be informative (e.g.) customer order id # is
> today's date + order number

I think you should create objects in database...

CREATE SEQUENCE seq1
 INCREMENT BY 1
 START WITH 1
 NOCYCLE
 CACHE 20
 NOORDER
;

CREATE OR REPLACE TRIGGER triggername
BEFORE INSERT
ON tablename
FOR EACH ROW
DECLARE
BEGIN
  :new.id:=seq1.nextval;
   ....
END;  
> The second case would be creating a pk that uses the concatenation of the
> first four letters of the fname and the first 4 letters of the lname.
> --
> Thanks & have a nice day! ;-)

CREATE OR REPLACE TRIGGER triggername
BEFORE INSERT
ON tablename
FOR EACH ROW
DECLARE
BEGIN
  :new.id:=substr(:new.fname,1,4)||substr(:new.lname,1,4);    ....
END;   Pawel Plichta
pp_at_inwar.com.pl
Invar System - Sieradz POLAND
Client-Server Department of Technology Received on Wed Jun 11 1997 - 00:00:00 CDT

Original text of this message

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