Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Get Owner of Trigger or Table in Trigger

Re: Get Owner of Trigger or Table in Trigger

From: Stephane Faroult <sfaroult_at_oriole.com>
Date: Thu, 16 Jan 2003 15:15:26 -0800
Message-ID: <F001.00532476.20030116151526@fatcity.com>


"Post, Ethan" wrote:
>
> Anyone know how to get the owner of a trigger inside a trigger without using
> the stack dump shown here by Tom Kyte which would still need some work to
> get just the owner name.
>
> http://groups.google.com/groups?q=get+table+owner+in+trigger+oracle&hl=en&lr
> =&ie=UTF-8&oe=UTF-8&selm=337efeab.1901213%40newshost&rnum=1
>
> I have the same trigger in same database in different environments
> (DEV,TEST,QA) and the trigger needs to send info using UTL_FILE to different
> directories based on which environment the trigger is in. Refreshes from
> production are automated but the production trigger get put in these other
> environments and I want the same trigger to run everywhere without
> modification. Current plan is to figure out the owner and set the path for
> UTL_FILE based on that.
>
> Any ideas.
>
> Thanks,
> Ethan

create table test (C NUMBER);
create trigger test_trig
before insert on test
is
  my_owner varchar2(30);
begin
  select a.owner
  into my_owner
  from v$access a,

       v$session s

  where s.audsid = sys_context('USERENV', 'SESSIONID')
    and s.sid = a.sid
    and a.object = 'TEST_TRIG'

create or replace trigger test_trig
before insert on test
declare
  my_owner varchar2(30);
begin
  select a.owner
  into my_owner
  from v$access a,

       v$session s

  where s.audsid = sys_context('USERENV', 'SESSIONID')
    and s.sid = a.sid
    and a.object = 'TEST_TRIG'
    and a.type = 'TRIGGER';

  dbms_output.put_line(my_owner);
end;
/

Trigger created.

SQL> set serveroutput on
SQL> insert into test values(1);
ORIOLE 1 row created.

SQL>

-- 
Regards,

Stephane Faroult
Oriole Software
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Stephane Faroult
  INET: sfaroult_at_oriole.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Thu Jan 16 2003 - 17:15:26 CST

Original text of this message

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