Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: USERENV('SESSION_ID') / auditing
Hi,
We also had wrote an error handler (which should log certain error
messages). I found out that selecting the sid from v$mystat always gives the
real sid, even in a job. v$mystat contains a lot of rows, but the sid is
always the same (per session), so doing a 'select sid from v$mystat where
rownum = 1' should be ok (or if you really want to be sure : 'select
distinct sid from v$mystat', and if you get a TOO_MANY_ROWS exception,
something is wrong).
We also thought of calling dbms_application_info and then checking the
corresponding column in v$session, but v$mystat looks easier.
Marc
Paul Berger wrote in message <3654E4D9.EA430804_at_bergersoftware.com>...
>As an aside: When utilizing userenv('sessionid') the value
>returned by this built-in actually matches the 'audsid'
>column within the v$session view...most of the time. The
>exceptions appears to be with Oracle system processes and when
>a session executes a PL/SQL object via Oracle's dbms_jobs.
>Userenv('sessionid') then registers an 'audsid' of 0, unfortunately.
>We wrote an error handler that exploits this association between
>userenv('sessionid') and v$session.audsid only to find this
>dbms_jobs restriction.
>
>Oracle will give you a unique session id via a call to one of
>the dbms built-ins...unique_session_id...but there appears to be no
>relationship back to any of the columns within any of the v$ views.
>Hence it's of limited use.
>
Received on Fri Nov 20 1998 - 00:34:51 CST