SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Hello !

 
Reply to topic    SoftTree Technologies Forum Index » DB Audit, DB Mail, DB Tools View previous topic
View next topic
Hello !
Author Message
ToanTranDuc



Joined: 28 Sep 2003
Posts: 2

Post Hello ! Reply with quote

: Hello,
: We would like to use dbmail inside a trigger.
: Does anyone have any code examples that we could use?

: thanks,
: Toan


Sun Sep 28, 2003 9:58 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7841

Post Re: Hello ! Reply with quote

Here is an example for Oracle. Similar code can be used with other database systems

CREATE OR REPLACE TRIGGER acct_change_email
ON accounts AFTER UPDATE
FOR EACH ROW
DECLARE
ret_code INTEGER := -1;
BEGIN
IF :new.acct_balance < 0 THEN
-- Insufficient funds.
-- Send email notification to the account manager
SELECT db_mail.send_mail(email,
'WARNING: Insufficient funds',
'Time: ' || SYSDATE || chr(10) ||
'Account: ' || :new.acct_nbr || chr(10) ||
'New balance: ' || :new.acct_balance, NULL)
INTO ret_code
FROM managers
WHERE id = :new.mgr_id

AND acct = :new.acct_nbr;
END;

Mon Sep 29, 2003 9:10 am View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » DB Audit, DB Mail, DB Tools All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.