After logon trigger [message #449867] |
Thu, 01 April 2010 14:01 |
Amine
Messages: 376 Registered: March 2010
|
Senior Member |
|
|
Hi All,
Is there a way to get the program the client is using in an after logon trigger ? This column is empty in v$session, and I think that it can be populated through DBMS_CLIENT_INFO...
Any ideas ??
Thanks
|
|
|
Re: After logon trigger [message #449878 is a reply to message #449867] |
Thu, 01 April 2010 16:11 |
gregor
Messages: 86 Registered: March 2010 Location: Germany
|
Member |
|
|
Hi Amine,
what do you want to know after-logon
"get the program the client is using"?
is that
a) in the form: the current-form-name : use :system.current_form
b) auditing logons/logoffs
create a LOGON and LOGOFF trigger
that populate a history table
c) you will have infos in V$SESSION-Table:
to use DBMS_APPLICATION_INFO.SET_MODULE (in forms)
is a good idea, to set fields in v$session
|
|
|
|
Re: After logon trigger [message #449880 is a reply to message #449867] |
Thu, 01 April 2010 16:57 |
gregor
Messages: 86 Registered: March 2010 Location: Germany
|
Member |
|
|
Hi Amine,
the DBMS_APPLICATION_INFO.set_module() must be set
in the Client(in FORMS,SQLPLUS/TOAD)_appilkation.
You an set this in your forms-module to a
value you like DBMS_APPLICATION_INFO.set_module('BINGBANG')
This is no allways possible.( exam. TOAD-Sessions)
-- generally when you can't set the "DBMS_APPLICATION_INFO.set_module()" because the user
uses SQLPLUS/TOAD
you can log connections with a database trigger:
create or replace TRIGGER TRG_LOGON_FILTER
AFTER
LOGON
ON DATABASE
declare
V_program varchar2(120);
...
begin
SELECT upper(program) into v_program FROM v$session where audsid=sys_context('USERENV','SESSIONID') and rownum=1;
if upper(v_program) in ('TOAD','SQLPLUS')) then
<write to protokoll-table>
end if;
end;
|
|
|
|
|
|
|
Re: After logon trigger [message #449929 is a reply to message #449926] |
Fri, 02 April 2010 06:55 |
|
Michel Cadot
Messages: 68686 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
Sorry I didn't see your version "sys_context('userenv','sid')" does not exist in 9i (iirc), you can use the following instead:
MICHEL> create table log (msg varchar2(200));
Table created.
MICHEL> create or replace trigger mytrg after logon on michel.schema
2 declare
3 l_module varchar2(100);
4 l_program varchar2(100);
5 begin
6 select module, program into l_module, l_program
7 from v$session where sid=(select sid from v$mystat where rownum=1);
8 insert into log values ('module: '||l_module||', program: '||l_program);
9 commit;
10 end;
11 /
Trigger created.
MICHEL> connect michel/michel
Connected.
MICHEL> select * from log;
MSG
---------------------------------------------------------------------------------
module: sqlplusw.exe, program: sqlplusw.exe
1 row selected.
Do not use "sys_context('userenv','sessionid')", it is not set at time of logon trigger.
Regards
Michel
|
|
|