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: Update trigger, detecting missing columns

Re: Update trigger, detecting missing columns

From: Maxim Demenko <mdemenko_at_arcor.de>
Date: Tue, 20 Dec 2005 18:30:03 +0100
Message-ID: <43a8401b$0$16513$9b4e6d93@newsread4.arcor-online.net>


Chris L. schrieb:
> Hello all,
>
> [Oracle 9i]
>
> Need to detect, in a "before update for each row" trigger, if a
> specific column had a value informed on the SQL statement.
>
> Example: Table ZZ with A, B, C columns
>
> update table ZZ set C=1 where A=2; (column B wasn't informed)
>
> update table ZZ set C=1,B=3 where A=2; (column B was informed)
>
> Assume both sentences hit one record. (A=Primary key)
>
> looking at :new.B doesn't help because that holds the value for B on
> that record.
> (If the record is A=2, B=1000, C=3, then :new.B evaluates to 1000 on
> the first update and to 3 on the second update).
>
> Any way to do it?
> Thanks in advance
> Cris
>

You can define a trigger which will fire only if column of interest is updated. Something like this:

CREATE OR REPLACE TRIGGER trg_z
BEFORE UPDATE OF B ON ZZ
FOR EACH ROW
BEGIN

Best regards

Maxim Received on Tue Dec 20 2005 - 11:30:03 CST

Original text of this message

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