Re: Trigger Question

From: Jeff Hunter <jeffh_at_btitelecom.net>
Date: 1999/09/13
Message-ID: <37dd2df2_at_defiant.btitelecom.net>#1/1


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 - 00:00:00 CEST

Original text of this message