I need to send data via http protocol (GET or POST request) from the function or trigger. Is it possible?
Syntax. CREATE TRIGGER trigger_name [BEFORE|AFTER|INSTEAD OF] event_name ON table_name [ -- Trigger logic goes here.... ]; Here, event_name could be INSERT, DELETE, UPDATE, and TRUNCATE database operation on the mentioned table table_name. You can optionally specify FOR EACH ROW after table name.
The responsible PostgreSQL process executes SQL specified in general configuration with parsed HTTP request as input to select the intended database and schema as well as authentication and request handler procedures to call there.
An INSTEAD OF trigger is a trigger that allows you to skip an INSERT , DELETE , or UPDATE statement to a table or a view and execute other statements defined in the trigger instead. The actual insert, delete, or update operation does not occur at all.
A PostgreSQL trigger is a function invoked automatically whenever an event associated with a table occurs. An event could be any of the following: INSERT, UPDATE, DELETE or TRUNCATE. A trigger is a special user-defined function associated with a table.
You could try writing the trigger in PL/Python and use urllib2 to POST.
There is an extension to do this, use with caution.
pgsql-http
Any "untrusted" language with HTTP support can do this:
but you shouldn't really do it. See Does PLV8 support making http calls to other servers? and why you shouldn't send email from a trigger function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With