Re: trigger question

From: <ajamoughlir_at_iccgcc.cle.ab.com>
Date: 24 Mar 95 16:12:47 EST
Message-ID: <1995Mar24.161247.1_at_iccgcc.cle.ab.com>


In article <3ksrg2$ccv_at_nsmmfs07.cscoe.ac.com>, lothmar_at_cscoe.ac.com (Mark Loth - DBA) writes:
> Recently a need has arisen within a project I support to monitor updates and inserts
> for certain database tables. I realize this can be done through auditing, but they
> would like to add USER_NAME and SYS_DATE columns to all monitored tables. I have
> been asked to write a trigger which would enter the appropriate user_name and sysdate
> into these columns for the appropriate row whenever an update or insert occurs on
> these tables. I was able to write a trigger for inserts, but I'm having no luck
> for updates.
>
> Can some please help? Any help would be greatly appreciated,
>
> Mark
> lothmar_at_cscoe.ac.com
>
>
try using :old and :new, write you trigger like:

if (updating and :old.user != :new.user) then

    update table

            set user_name := :new.user;
end if;

for more information refere to ORACLE7 server concepts manual chapter 15. hope this helps
good luck ;-)

Raghid Ajamoughli
AJAMOUGHLIR_at_beast.cle.ab.com Received on Fri Mar 24 1995 - 22:12:47 CET

Original text of this message