Is it possible to create an insert trigger in a "Table1" using "CREATE TEMP TABLE" in its structure and feed a "Table2"?
Is it possible to create an insert trigger in a "Table1" using "CREATE TEMP TABLE" in its structure and feed a "Table2"?
I do not quite understand what you want to do, but you can create temporary tables in your trigger.
Ex:
CREATE OR REPLACE FUNCTION f_table1_tbi() RETURNS TRIGGER AS $$
BEGIN
CREATE TEMPORARY TABLE table2 ON COMMIT DROP AS
SELECT NEW.*;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER table1_tbi BEFORE INSERT
ON table1 FOR EACH ROW EXECUTE PROCEDURE f_table1_tbi();
In this case, the temporary table table2 will be deleted when you commit.