“Postgres Trigger Insert em outra tabela” Respostas de código

Postgres Trigger Insert em outra tabela

CREATE OR REPLACE FUNCTION function_copy() RETURNS TRIGGER AS
$BODY$
BEGIN
    INSERT INTO
        table2(id,name)
        VALUES(new.id,new.name);

           RETURN new;
END;
$BODY$
language plpgsql;
Thoughtful Tuatara

Postgres Trigger Insert em outra tabela

CREATE TRIGGER trig_copy
     AFTER INSERT ON table1
     FOR EACH ROW
     EXECUTE PROCEDURE function_copy();
Thoughtful Tuatara

Postgres inserir no valor da tabela de outra tabela

##fetch data from other table with sub-query to insert it into another one

INSERT INTO PUBLIC."MyTable"(conversion_job_id, message, last_status)
VALUES (17, 'test', (SELECT status FROM PUBLIC."OtherTable" WHERE id=17))
RETURNING *
Wide-eyed Fox

Respostas semelhantes a “Postgres Trigger Insert em outra tabela”

Perguntas semelhantes a “Postgres Trigger Insert em outra tabela”

Mais respostas relacionadas para “Postgres Trigger Insert em outra tabela” em Sql

Procure respostas de código populares por idioma

Procurar outros idiomas de código