Technological recipes that I've held to prepare some solutions DBA environment. (by Felipe Donoso Bastias)

29 Oct 2007

Enviar correo al loguearse en Oracle

Este pequeño script permite enviar un correo al hacer un loggin con un usuario x del motor de base de datos, obviamente el usuario se puede ajustar:

create or replace trigger audit_scott
after logon on database
declare x varchar2(50);
begin
select to_char(sysdate, 'DD-MM-YYYY HH24:MI:SS') into x from dual;
if sys_context('userenv','session_user') = 'SCOTT' then
sys.mailsend (
sender => 'oracle@dizwellmail.com',
recipient => 'hjr@dizwellmail.com',
mail_subject => 'SCOTT has logged on',
mail_body => 'Scott logged on at '||x||'!');
end if;
end;
/


Como siempre espero que lo disfruten.
Saludos.
Share:

Copyright © DBA TIPS | Powered by Blogger
Design by SimpleWpThemes | Blogger Theme by NewBloggerThemes.com | Free Blogger Templates