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: Joel R. Kallman <jkallman_at_us.oracle.com>
Date: 1998/11/23
Message-ID: <3659a07f.3855844@newshost.us.oracle.com>#1/1

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
>??

No...this is a trigger on the table RANDI_MATING, and it is going to reference each row when this trigger fires as "n". So the statement:

        :n.fld_pk := new_key

is assigning the value of the variable "new_key" to the *column* "FLD_PK". FLD_PK is a column of the RANDI_MATING table.
>
>-jh
>NORWAY
>
>

Thanks!

Joel

Joel R. Kallman Oracle Government, Education, & Health

Columbus, OH                             http://govt.us.oracle.com
jkallman@us.oracle.com                   http://www.oracle.com



The statements and opinions expressed here are my own and do not necessarily represent those of Oracle Corporation. Received on Mon Nov 23 1998 - 00:00:00 CST

Original text of this message

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