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: New to Triggers - Help Please -

Re: New to Triggers - Help Please -

From: Bob Cunningham <bcunn_at_cucomconsultants.com>
Date: Sat, 28 Aug 1999 02:39:07 GMT
Message-ID: <37c749bf.252215121@news.telusplanet.net>


On Fri, 27 Aug 1999 08:57:27 -0700, "Mike M." <okana_at_msn.com> wrote:

It would be similar to those you've written. If the outcome is being changed to something it shouldn't be, then just change it back to what it should be and let the operation proceed.

Something like:

CREATE OR REPLACE TRIGGER triggername
BEFORE UPDATE ON Customers
FOR EACH ROW
BEGIN
  IF :OLD.outcome = 14500
  AND :NEW.outcome IN (11000, 11001, 12000) THEN     :NEW.outcome := 14500;
  END IF;
END;
>I am just starting to write my own triggers and I have a big project ahead
>of me that may involve several of them - I already have several that
>evaluate and assign values upon inserts - those were a piece of cake - but
>now I'm dealing with data validation.
>
>Here is the first one - and I'm not sure where the error is, actually I'm
>not even sure I'm doing it right.
>
>I was using the GUI to try and design it, but a SQL statement will work fine
>if I someone wants to assist me -
>
>Oracle 8.05 on NT4
>
>Table: Customers
>Column: OUTCOME
>
>Before update on row: if old.outcome = 14500 and new.outcome in (11000,
>12000, 11001) then new.outcome = 14500
>
>In other words, if the new outcome code is 11000, 12000 or 11001 then don't
>change it. And I don't need an error raised to the user.
>
>Some assistance would be greatly appreciated -
>
>Mike
>mikem_at_msamail.com
>okana_at_msn.com
>
>
>
>
>
>
Received on Fri Aug 27 1999 - 21:39:07 CDT

Original text of this message

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