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;
##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 *
INSERT INTO holiday_calender (hcl_country,hcl_company,hcl_date,hcl_description,hcl_active) VALUES
(2,1,'2022-05-21 00:00:00','Holiday 1',1),
(2,1,'2022-05-22 00:00:00','Holiday 2',1),
(2,1,'2022-05-23 00:00:00','Holiday 3',1),
(2,1,'2022-05-25 00:00:00','Holiday 4',1),
(2,1,'2022-05-26 00:00:00','Holiday 5',1),
(2,1,'2022-05-28 00:00:00','Holiday 6',1);
INSERT INTO table_name(column1, column2, …)
VALUES (value1, value2, …);
Code language: SQL (Structured Query Language) (sql)
INSERT INTO table_name(column1, column2, …)
VALUES (value1, value2, …)
RETURNING *;Code language: SQL (Structured Query Language) (sql)