Solved

Cannot select V$SESSION in before LOGOFF trigger

Posted on 2007-12-06
4
1,056 Views
Last Modified: 2008-02-01
Do you know why I cannot compile this trigger?

CREATE OR REPLACE TRIGGER LOGOFF_TRIGGER
BEFORE LOGOFF ON DATABASE
DECLARE
BEGIN
  insert into TEST
  (USERNAME)
  select distinct USERNAME
  from V$SESSION;
END;
/
0
Comment
Question by:Zopilote
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Expert Comment

by:joebednarz
ID: 20422654
Not sure "why" it does that... but try this instead:

create trigger logoff_trigger
before logoff on database
begin
  insert into test values(sys_context('userenv','session_user'));
end;
/
0
 
LVL 5

Author Comment

by:Zopilote
ID: 20423682
Problem solved. No direct grant.
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 50 total points
ID: 20423683
whomever owns the trigger doesn't have select access on v$session.

I was able to compile your trigger fine and it ran correctly as well.
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 20423687
sorry, didn't see your post.  yes, you are correct, that's "why"

sys_context is a good workaround too
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question