All Forums Database
SAP 73 posts Joined 08/14
27 Sep 2014
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 !!!

SAP
SAP 73 posts Joined 08/14
27 Sep 2014

Please no C/C++ UDF . 

SAP

SAP 73 posts Joined 08/14
27 Sep 2014

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

SAP

tomnolan 594 posts Joined 01/08
29 Sep 2014

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.

frnewbrough 41 posts Joined 03/08
02 Oct 2014

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!');

 
 

 

frnewbrough 41 posts Joined 03/08
02 Oct 2014

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.

Raja_KT 1246 posts Joined 07/09
03 Oct 2014

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 ?  :)

Raja K Thaw
My wiki: http://en.wikipedia.org/wiki/User:Kt_raj1
Street Children suffer not by their fault. We can help them if we want.

You must sign in to leave a comment.