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: Which column is being updated

Re: Which column is being updated

From: Martin Haltmayer <Martin.Haltmayer_at_0800-einwahl.de>
Date: Wed, 18 Apr 2001 23:24:53 +0200
Message-ID: <3ADE0625.BD652321@0800-einwahl.de>

Try the following example:

SQL> create table testtab (n number, a varchar2 (50), d date);

Table created.

SQL>
SQL> create or replace trigger testtrigg   2 after update
  3 of n, a
  4 on testtab
  5 begin

  6  	     if updating ('N') then
  7  		     dbms_output.put_line ('updating N...');
  8  	     end if;
  9  	     if updating ('A') then
 10  		     dbms_output.put_line ('updating A...');
 11  	     end if;

 12 end testtrigg;
 13 /

Trigger created.

SQL> 
SQL> set serveroutput on size 1000000
SQL> 
SQL> insert into testtab (n, a, d) values (5, 'abc', sysdate);

1 row created.

SQL>
SQL> update testtab set n = 6;
updating N...

1 row updated.

SQL> update testtab set a = 'bbb';
updating A...

1 row updated.

SQL> update testtab set n = 8, a = 'def';

updating N...                                                                   
updating A...                                                                   

1 row updated.

SQL> update testtab set d = sysdate - 1;

1 row updated.

SQL>
SQL> commit;

Commit complete.

Martin

Simon Irvin wrote:
>
> Is there any way I can make use of whatever information Oracle uses to
> decide whether or not to fire a trigger that is only invoked on updates to a
> subset of the columns in a table. (Hope that makes sense!) What I suppose I
> mean is when you define a trigger to be fired on "UPDATE OF column1" how
> does Oracle know it is column1 that has been updated and can I obtain the
> same information?
>
> Cheers
>
> Simon Irvin
Received on Wed Apr 18 2001 - 16:24:53 CDT

Original text of this message

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