“postgres memicu insert ke tabel lain” Kode Jawaban

postgres memicu insert ke tabel lain

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 memicu insert ke tabel lain

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

Postgres memasukkan ke nilai tabel dari tabel lain

##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

Jawaban yang mirip dengan “postgres memicu insert ke tabel lain”

Pertanyaan yang mirip dengan “postgres memicu insert ke tabel lain”

Lebih banyak jawaban terkait untuk “postgres memicu insert ke tabel lain” di Sql

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya