1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] How can I send email from PostgreSQL trigger?

Discussão em 'Outras Linguagens' iniciado por Stack, Outubro 6, 2024 às 10:43.

  1. Stack

    Stack Membro Participativo

    I using pgsql to set a trigger, when update the table dataset(change the status to Finished) it will automatic send a email to the email account using dataset email value and save this email in server

    but i don't know how to write in trigger function to send email, and send email in server. Thank you in advance

    Pg version is 9.1, and CentOS 5.8

    CREATE OR REPLACE FUNCTION sss()
    RETURNS trigger AS
    $BODY$begin
    if(NEW.publisher== 'aaaa')
    then
    //send email and save to server 192.168.171.64
    end if;
    return NEW;
    end

    $BODY$
    LANGUAGE plpgsql VOLATILE
    COST 100;
    ALTER FUNCTION sss()
    OWNER TO postgres;
    GRANT EXECUTE ON FUNCTION sss() TO postgres;

    Continue reading...

Compartilhe esta Página