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

Home -> Community -> Usenet -> c.d.o.tools -> log changes trigger

log changes trigger

From: Jonas Malmsten <deja_at_malmsten.net>
Date: Wed, 17 Jan 2001 17:02:34 GMT
Message-ID: <944j73$59h$1@nnrp1.deja.com>

I need to write a trigger to log changes made to a table and by who these changes were made. I have created a log table having a field user_name varchar2(30) where I intend to store the username for anyone who changed the my_table, along with the previous values, before it was changed. Currently my trigger looks something like this (I dont need to log delete och insert events).

create or replace trigger tr_u_my_table
after update on my_table
for each row
  uname varchar2(30);
begin
  select username into uname
    from v$session where audsid = userenv('SESSIONID');   insert into my_log
(username, change_date, other_fields...)
    values
(uname, sysdate, :old.other_fields...);
end;
/

My problem is that not all users have permission to select from v$session. Is there another way to do this or do I need to grant select on v$session to all_users?

//Jonas

Sent via Deja.com
http://www.deja.com/ Received on Wed Jan 17 2001 - 11:02:34 CST

Original text of this message

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