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

thanks, Sal Emma

Thu Sep 11, 2003 5:11 pm

SysOpSite Admin

Joined: 26 Nov 2006Posts: 6579

Re: DBMAIL in a trigger....

For sample code please see examples in the DB Mail online help. It does not really matter where you call DB Mail - from a trigger from a stored procedure or from a function. It is all the same. As long as you know how to write a trigger it should be fairly simple. If you are not familiar with triggers please see trigger examples available in Oracle documentation and in large quantities on the Internet

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

: thanks, : Sal Emma

Thu Sep 11, 2003 10:50 pm

Sal emma

Joined: 12 Sep 2003Posts: 4

Re: DBMAIL in a trigger....

: For sample code please see examples in the DB Mail online help. It does not : really matter where you call DB Mail - from a trigger from a stored : procedure or from a function. It is all the same. As long as you know how : to write a trigger it should be fairly simple. If you are not familiar : with triggers please see trigger examples available in Oracle : documentation and in large quantities on the Internet

Do I have to set up a stored procedure to execute from the trigger? What is the syntax of the send_email function to simply send an email with the :new.values to a :new.emailaddress in a before insert trigger? Your help is greatly appreciated. Thanks very much. Sal Emma

Fri Sep 12, 2003 10:39 am

SysOpSite Admin

Joined: 26 Nov 2006Posts: 6579

Re: DBMAIL in a trigger....

In PL/SQL you cannot just do a SELECT. It must be either INSERT INTO [table]..SELECT or SELECT..INTO [variables]

If you just want to send email using known parameters (no need to do any SELECT) just call this function direcly as below

RETURN_VAR := function( [function arguments here] );

Therefore for SEND_MAIL you would have

RETURN_VAR := SEND_MAIL( [function arguments here] );

: ' : If I call the send_mail in a select statement in a trigger, : oracle tells me that it is expecting an "into" clause.

: Do I have to set up a stored procedure to execute from the trigger? : What is the syntax of the send_email function to simply send an email with : the : Your help is greatly appreciated. : Thanks very much. : Sal Emma

Fri Sep 12, 2003 12:53 pm

ToanTranDuc

Joined: 28 Sep 2003Posts: 2

Re: DBMAIL in a trigger....

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