Send mail from a stored procedure

Database
SAP
Enthusiast

Send mail from a stored procedure

Hi , 

i have an requirement to send mail from a stored procedure when there is an any error faced inside the stored procedure .

Thanks !!!

6 REPLIES
SAP
Enthusiast

Re: Send mail from a stored procedure

Please no C/C++ UDF . 

SAP
Enthusiast

Re: Send mail from a stored procedure

and no bteq scripts !!! I need to write it in either strored proc or macro 

Teradata Employee

Re: Send mail from a stored procedure

You cannot send mail from a SQL stored procedure, or from a macro.

You can send mail from a External Stored Procedure written in either C or Java. There is an example showing how to send mail listed in the Teradata Database Reference / SQL External Routine Programming / Appendix B: External Stored Procedure Code Examples.

Teradata Employee

Re: Send mail from a stored procedure

You have another option provided you have a viewpoint server available and have configured it correctly to send mail which I would assume you do.


INSERT dbcmngr.alertrequest VALUES (date, time, 'Job1', 'Load job

completed', 0, 'E', 20, 'your.name@email.com',

'This message indicates that the load job completed!');

Teradata Employee

Re: Send mail from a stored procedure

Here is the user guide:

http://www.info.teradata.com/edownload.cfm?itemid=122790011

Check the section "About Alerts in Teradata Database" for more interesting and useful examples.

Enthusiast

Re: Send mail from a stored procedure

My opinion:

Stored Procs, functions, packages are objects with different intents. They are meant for modularizing our programs. Each and every business functionality is mapped to technology objects with proper naming convention for ease of demarcating departments....

Sending an email from within stored proc is a bad design. Mc Donalds, Pizza hut etc have cashier counter and kitchen separately....

Let the pizza or hamburger be cooked in the kitchen and once that is done, hand it over to the neat and clean counter to hand it over to the customer. Why do we want that delivery should happen inside the kicthen ?  :)