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: Trigger Question

Re: Trigger Question

From: Michael Milliron <~okana_at_msn.com>
Date: Mon, 13 Sep 1999 10:38:49 -0700
Message-ID: <khdD3.3444$R_.20185717@news5.usenetserver.com>


thank you -
  Jeff Hunter <jeffh_at_btitelecom.net> wrote in message = news:37dd2df2_at_defiant.btitelecom.net...   No question is a stupid question.

  You can use the "user" keyword in your trigger PL/SQL block to return = the current user. Although triggers run as the owner of the object, the = user will return the user who is causing the trigger to fire...

  SQL> select user, sysdate from dual;    

  USER                           SYSDATE
  ------------------------------ ---------
  SYSTEM                         13-SEP-99

  In a trigger it would look like:

  CREATE OR REPLACE TRIGGER ANI_AUDIT

     AFTER INSERT OR UPDATE OR DELETE ON ANI
     REFERENCING NEW AS NEW OLD AS OLD
     FOR EACH ROW
   
  BEGIN
     IF INSERTING THEN
        INSERT INTO ANI_AUDIT (user_id, audit_ts, action_cd, id, ani)
        VALUES (user,sysdate,'INSERT',:new.id, :new.ani);

     END IF;

  END;   Michael Milliron <~okana_at_msn.com> wrote in message ...
>This may be a stupid question:
>
>In using triggers - I am doing an insert into a separate table based =
on an
>update or insert into a table. Is there a way to get the Oracle user =
ID of
>the person performing the update from within the trigger to use in =
the
>insert statment?
>
>
>Michael Milliron
>mikem_at_msamail.com
>okana_at_msn.com
>
>
>
>
Received on Mon Sep 13 1999 - 12:38:49 CDT

Original text of this message

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