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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Trigger for inserting new primary keys in a table ... How ??

Re: Trigger for inserting new primary keys in a table ... How ??

From: Nicolas Bronke <NBronke_at_t-online.de>
Date: 1998/11/23
Message-ID: <73cd9l$39c$1@news00.btx.dtag.de>#1/1

No. There goes something wrong. First you have to create a sequence. Try following:

create sequence sysLog$GenId
 INCREMENT BY 1
 CACHE 10
 ORDER; create or replace trigger sysLog$TGBI
before insert on sysLog for each row
Declare n sysLog.nId%Type;
begin
  select SYSLOG$GENID.NEXTVAL INTO N from DUAL;   :new.nId:=N;
end sysLog$TGBI;
/
Syslog is my table. nId is the primary key of syslog. You may name the trigger as you want. Above is my syntax.

Regards
Nicolas Bronke

Jørgen Haukland schrieb in Nachricht <73c29l$pnd_at_info.telenor.no>...
>Hello !
>
>I picked this one from somewhere on the net, but it won'work for me. It is
>supposed to insert a new primary key when one enters a new value in my
 table
>(I get an error message on the n.fld_pk syntax) Here it is:
>
>CREATE OR REPLACE TRIGGER TRIGGER_PRIMARYKEY
> BEFORE INSERT ON RANDI_MATING
> /* RANDI_MATING is my table name */
> REFERENCING NEW AS n
> FOR EACH ROW
>DECLARE
> new_key INTEGER;
>BEGIN
> SELECT test_id.NEXTVAL INTO new_key FROM DUAL;
> /*test_id is my primaryke column*/
> :n.fld_pk := new_key;
>END;
>
>
>I think maybe fld_pk refers to a package that I don't have. Any suggestions
Received on Mon Nov 23 1998 - 00:00:00 CST

Original text of this message

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