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: Overiding triggers!

Re: Overiding triggers!

From: Arjan van Bentem <avbentem_at_DONT-YOU-DAREdds.nl>
Date: Thu, 18 Feb 1999 17:19:01 +0100
Message-ID: <36cc3d78$0$29964@newton>


George wrote
>An insert trigger assigns a sequence
>value to a field. However on some insert events
>I would like to assign a value from another source
>to this field.

For this very example, I'd simply check if a value is supplied. If not, then get one in the trigger:

create or replace trigger my_trigger
before insert or update of my_table
begin
  if :new.my_column is null then

      if inserting then
          select my_sequence.next_val
          into :new.my_column
          from dual;
      else -- updating
          raise_application_error(-2000, 'Cannot set my_column to
null');
      end if;

end;

Arjan. Received on Thu Feb 18 1999 - 10:19:01 CST

Original text of this message

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