UDF for calling Email sending program

Connectivity
Enthusiast

UDF for calling Email sending program

Hello there,
I am looking for a custom UDF which would have the following signature:
Input:
1. From Email addr. 2.To Email addr(s) 3. Subject line 4. Body Text
Output:
Status code

This is to use the UDF to send emails.
Do we have something readily available for this ?

Thanks in advance

1 REPLY
rgs
Enthusiast

Re: UDF for calling Email sending program

There is a sample external procedure for Teradata running on UNIX (MPRAS, Linux) for sending email in the user documentation. See “SQL Reference, UDF, UDM, and External Stored Procedure Programming”, release V2R6.1 (and later). See appendix C. This is the prototype:

REPLACE PROCEDURE tdmail(
in From_ VARCHAR(100),
in To_ VARCHAR(100),
in Subject VARCHAR(200),
in Message VARCHAR(32000))
LANGUAGE C
NO SQL
PARAMETER STYLE SQL
EXTERNAL name 'CS!tdmail!tdmail.c'
EXTERNAL SECURITY DEFINER;

You probably don’t want to set it up as a UDF, because you could end up sending the same email hundreds of times unintentionally, depending on the SQL statement you invoke the UDF in. Remember the database runs SQL in parallel, including UDFs, i.e., many instances at once. Of course if you set it up to send email for different rows for a table it would work, but you would probably make your UNIX system administrator very unhappy because it could overrun their email system very quickly, spam comes to mind.