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: Trigger for inserting new primary keys in a table ... How ??

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

From: Jonathan Gennick <gennick_at_worldnet.att.net>
Date: 25 Nov 1998 04:05:15 GMT
Message-ID: <366878f6.5417859@netnews.worldnet.att.net>


This trigger is written for a table that has a field named FLD_PK as it's primary key. It also expects an Oracle sequence named TEST_ID to exist. Have you tried changing the FLD_PK reference to match the name of your table's primary key?

Jonathan



Jonathan Gennick
gennick_at_worldnet.att.net
http://home.att.net/~gennick
coauthor: Teach Yourself PL/SQL in 21 Days Brighten the corner where you are.

On Mon, 23 Nov 1998 17:25:24 +0100, "Jørgen Haukland" <jorgen.hauikland_at_fou.telenor.no> wrote:

>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
>??
>
>-jh
>NORWAY
>
Received on Tue Nov 24 1998 - 22:05:15 CST

Original text of this message

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