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 -> INSERT trigger doesn't work...why not?

INSERT trigger doesn't work...why not?

From: John Haskins <76054.334SPAMBEGONE_at_compuserve.com>
Date: Fri, 05 Nov 1999 00:08:37 GMT
Message-ID: <9epU3.669$_Y3.23808@dfiatx1-snr1.gtei.net>


Greetings:

I've created a simple trigger to ensure that new records always have an ID number. The trigger checks whether the ID column is null, and if so, uses a sequence to generate a value to include. However, the trigger is being ignored. (Yes, it's enabled.) I'd appreciate if anyone has an idea about what to do to make it get used.

The trigger is:
create or replace trigger cc.person_insert_trigger  before insert
 on cc.person
 for each row
 when (new.person_id is null)
 begin
  insert into cc.person(

   person_id,
   person_last_name,
   person_first_name,
   person_middle_name

)

  values (
   cc.person_s.nextval,
   :new.person_last_name,
   :new.person_first_name,
   :new.person_middle_name

)

  ;
 end;
/

When I issue this DML command:
insert into person (

  person_last_name,
  person_first_name,
  person_middle_name

)

 values ('ZZZ Test',
  'ZZZ Test first',
  'ZZZ test middle'
)

 ;

I get the following PL/SQL error message: insert into person (

            *
ERROR at line 1:
ORA-01400: cannot insert NULL into ("CC"."PERSON"."PERSON_ID")

Any assistance on this will be much appreciated! Received on Thu Nov 04 1999 - 18:08:37 CST

Original text of this message

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