Monday, July 30, 2007

Trigger to backup table and send mail

create or replace trigger dominic_details
before insert on system.details2 referencing old as old new as new for each row
declare
l_maicon utl_smtp.connection;
begin
insert into details2_master values(:new.name,:new.marks);
l_maicon :=utl_smtp.open_connection('192.168.1.119');
utl_smtp.helo(l_maicon,'oracle');
utl_smtp.mail(l_maicon,'dominic@isteducation.com');
utl_smtp.rcpt(l_maicon,'dominic@isteducation.com');
utl_smtp.data(l_maicon,'From: dominic@isteducation.com' || utl_tcp.crlf||
'To: dominic@isteducation.com' || utl_tcp.crlf ||
'Subject: Insert into details2 table' || utl_tcp.crlf ||
'name '||:new.name ||' marks '||:new.marks);
utl_smtp.quit(l_maicon);
end;
/

No comments: