Re: Query-Sending mail from PostgresSQL

From: Christopher Browne <cbbrowne(at)gmail(dot)com>
To: Ramesh Rajamanickam <rameshr(dot)bnk(at)gmail(dot)com>
Cc: PostgreSQL Mailing Lists <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Query-Sending mail from PostgresSQL
Date: 2016-02-25 17:36:33
Message-ID: CAFNqd5VUbsQzqP57j3CpsmVuaBAVX-+dxqCOSfgwx1cHgejVrA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 24 February 2016 at 22:40, Ramesh Rajamanickam <rameshr(dot)bnk(at)gmail(dot)com>
wrote:

>
> Hi,
>
> We are using Postgres. Doing migration from Oracle to Postgres SQL. Now we
> wanted to migrate the Sending mail operation as in oracle. Searched the
> help couldn't able to find the solution. Below is the oracle statement
> used.
>
> UTL_MAIL.send(
> sender => EMAIL_DIST,
> recipients => EMAIL_DIST,
> cc => EMAIL_DIST,
> bcc => EMAIL_DIST,
> subject => Load_Name ,
> message => emesg
> );
>
> Please give your suggestion how we can migrate the above statement to
> Postgres.
>

It is not particularly reasonable to consider this to be a "bug", as that
tends to constitute some form of "incorrect behaviour."

That there is no function to submit email is not reasonably "incorrect
behaviour."

That said, I would not recommend implementing such a function in any case,
as this represents functionality that would not be able to run
transactionally (e.g. - with capability to roll back on error, and roll
back submitted email).

Instead, I would recommend implementing a function, perhaps with much the
same API, which inserts the specified data into a table in the database,
and then construct some external component to pull email from that table
and submit it. That would have much better performance characteristics
(via conscious batch processing) than some API that opens a connection to
an SMTP server dynamically each time the function is called.
--
When confronted by a difficult problem, solve it by reducing it to the
question, "How would the Lone Ranger handle this?"

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Dean Rasheed 2016-02-25 23:32:12 Re: BUG #13988: "plan should not reference subplan's variable" whilst using row level security
Previous Message Andres Freund 2016-02-25 17:29:58 Re: BUG #13985: Segmentation fault on PREPARE TRANSACTION