Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Anybody ever tried to use ON_LOGON triggers?
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C0247B.E0CA064C
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Yes, and it works (aix 4.3.2 / Oracle 8.1.6.1.0)
create or replace trigger user_logon after logon on database
declare
cursor c1 is
select v1.username, v1.osuser, v1.logon_time, v1.terminal
from v$session v1
where v1.username=3Duser;
my_user varchar2(30); my_os varchar2(39); my_time date; my_term varchar2(10);
for x in c1 loop
fetch c1 into my_user,my_os,my_time,my_term;
insert into user_logon values(my_user,my_os,my_time,my_term);
commit;
end loop;
end;
Table and trigger created as system, grant v%_session from sys to = system
good luck
Vincent Ruger
(Oracle DBA)
-----Oorspronkelijk bericht-----
Van: root_at_fatcity.com [mailto:root_at_fatcity.com]Namens Rahul
Verzonden: vrijdag 22 september 2000 12:15
Aan: Multiple recipients of list ORACLE-L
Onderwerp: RE: Anybody ever tried to use ON_LOGON triggers?
I tried this and DID NOT work(metalink is wrong about this)=20
it returns SYS's sessionid always...
so i use the following..
WHERE username =3D user
and logon_time =3D (select max(logon_time) from sys.v_$session where
username=3Duser)
> ----------
> From: Schoen Volker[SMTP:v.schoen_at_inplan.de]
> Sent: Friday, September 22, 2000 3:13 PM
> To: 'Vergara, Michael (TEM)'; 'Oracle DBA List (Quickdoc)'
> Subject: AW: Anybody ever tried to use ON_LOGON triggers?
>=20
>=20
>=20
>=20 >=20 >=20
>=20 >=20
>=20
>=20
>=20
>=20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> Michael P. Vergara | I do it for the stories I can tell
> Guidant Corporation | - John Sebastian
> Oracle DBA |
>=20 >=20 >=20
>=20
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists --------------------------------------------------------------------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).
------_=_NextPart_001_01C0247B.E0CA064C
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD> <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =charset=3Diso-8859-1">
<TITLE>RE: Anybody ever tried to use ON_LOGON triggers?</TITLE> </HEAD> <BODY>
<P><FONT SIZE=3D2>Yes, and it works (aix 4.3.2 / Oracle =
8.1.6.1.0)</FONT>
</P>
<P><FONT SIZE=3D2>create or replace trigger user_logon after logon on = database</FONT>
<BR><FONT SIZE=3D2>declare</FONT> <BR><FONT SIZE=3D2>cursor c1 is</FONT> <BR><FONT SIZE=3D2>select v1.username, v1.osuser, v1.logon_time, =v1.terminal</FONT>
<BR><FONT SIZE=3D2>from v$session v1</FONT> <BR><FONT SIZE=3D2>where v1.username=3Duser;</FONT> <BR><FONT SIZE=3D2>my_user varchar2(30);</FONT> <BR><FONT SIZE=3D2>my_os varchar2(39);</FONT> <BR><FONT SIZE=3D2>my_time date;</FONT> <BR><FONT SIZE=3D2>my_term varchar2(10);</FONT> <BR><FONT SIZE=3D2>begin</FONT> </P>
<P><FONT SIZE=3D2>for x in c1 loop</FONT>
<BR><FONT SIZE=3D2> fetch c1 into =
my_user,my_os,my_time,my_term;</FONT>
<BR><FONT SIZE=3D2> insert into user_logon =
values(my_user,my_os,my_time,my_term);</FONT>
<BR><FONT SIZE=3D2> commit;</FONT> <BR><FONT SIZE=3D2>end loop;</FONT> </P>
<P><FONT SIZE=3D2>end;</FONT>
</P>
<P><FONT SIZE=3D2>Table and trigger created as system, grant v%_session =
from sys to system</FONT>
</P>
<P><FONT SIZE=3D2>good luck</FONT>
</P>
<P><FONT SIZE=3D2>Vincent Ruger</FONT> <BR><FONT SIZE=3D2>(Oracle DBA)</FONT> </P>
<P><FONT SIZE=3D2>-----Oorspronkelijk bericht-----</FONT> <BR><FONT SIZE=3D2>Van: root_at_fatcity.com [<A = HREF=3D"mailto:root_at_fatcity.com">mailto:root_at_fatcity.com</A>]Namens = Rahul</FONT>
<BR><FONT SIZE=3D2>Verzonden: vrijdag 22 september 2000 12:15</FONT> <BR><FONT SIZE=3D2>Aan: Multiple recipients of list ORACLE-L</FONT> <BR><FONT SIZE=3D2>Onderwerp: RE: Anybody ever tried to use ON_LOGON =triggers?</FONT>
<P><FONT SIZE=3D2>I tried this and DID NOT work(metalink is wrong about = this) </FONT>
<BR><FONT SIZE=3D2> it returns SYS's sessionid always...</FONT> <BR><FONT SIZE=3D2>so i use the following..</FONT> </P>
<P><FONT SIZE=3D2>WHERE username =3D user</FONT> <BR><FONT SIZE=3D2>and logon_time =3D (select = max(logon_time) from sys.v_$session where</FONT>
<BR><FONT SIZE=3D2>username=3Duser)</FONT> </P> <BR> <BR>
<P><FONT SIZE=3D2>> ----------</FONT>
<BR><FONT SIZE=3D2>> From: =
Schoen =
Volker[SMTP:v.schoen_at_inplan.de]</FONT>
<BR><FONT SIZE=3D2>> Sent: =
Friday, September 22, 2000 =
3:13 PM</FONT>
<BR><FONT SIZE=3D2>> To: 'Vergara, Michael (TEM)'; 'Oracle =
DBA List (Quickdoc)'</FONT>
<BR><FONT SIZE=3D2>> Subject: AW: Anybody =
ever tried to use ON_LOGON triggers?</FONT>
<BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> Hi Mike,</FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> try to select the infos from v$session, I think =it should work, haven't</FONT>
<BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> Regards</FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> Volker Sch=F6n</FONT> <BR><FONT SIZE=3D2>> E-Mail: <A =
<BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> -----Urspr=FCngliche Nachricht-----</FONT> <BR><FONT SIZE=3D2>> Von: Vergara, Michael (TEM) [<A =HREF=3D"mailto:mvergara_at_guidant.com">mailto:mvergara_at_guidant.com</A>]</F=
ONT> <BR><FONT SIZE=3D2>> Gesendet: 21. September 2000 19:51</FONT> <BR><FONT SIZE=3D2>> An: 'Oracle DBA List (Quickdoc)'</FONT> <BR><FONT SIZE=3D2>> Betreff: Anybody ever tried to use ON_LOGON =triggers?</FONT>
<BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> Hi DBAs!</FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> I experimenting with ON_LOGON triggers, =learning about them as a step</FONT>
<BR><FONT SIZE=3D2>> I cannot get something to work.</FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> I'm trying to get the user's session id from =within the trigger. I've</FONT>
<BR><FONT SIZE=3D2>> tried to use SYS_CONTEXT('USERENV','SESIONID') = and </FONT> <BR><FONT SIZE=3D2>> USERENV('SESSIONID') and both return '0' from =within the trigger. Now</FONT>
<BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> Anybody?</FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> TIA,</FONT> <BR><FONT SIZE=3D2>> Mike</FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> ---</FONT> <BR><FONT SIZE=3D2>> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D==3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</FONT= >
<BR><FONT SIZE=3D2>> Guidant Corporation = |  = ;  =; - John Sebastian</FONT>
<BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> --------</FONT> <BR><FONT SIZE=3D2>> If you're bored, then visit the list's website: = <A HREF=3D"http://www.lazydba.com" =
<BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> --------</FONT> <BR><FONT SIZE=3D2>> If you're bored, then visit the list's website: = <A HREF=3D"http://www.lazydba.com" =
<BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>-- </FONT> <BR><FONT SIZE=3D2>Please see the official ORACLE-L FAQ: <A =HREF=3D"http://www.orafaq.com" =
<BR><FONT SIZE=3D2>-- </FONT> <BR><FONT SIZE=3D2>Author: Rahul</FONT> <BR><FONT SIZE=3D2> INET: rahul_at_ratelindo.co.id</FONT> </P>
<P><FONT SIZE=3D2>Fat City Network Services -- (858) =
538-5051 FAX: (858) 538-5051</FONT>
<BR><FONT SIZE=3D2>San Diego, =
California -- Public Internet =
access / Mailing Lists</FONT>
<BR><FONT =
SIZE=3D2>---------------------------------------------------------------=-----</FONT>