Perhaps you can get the result you are looking for using simple queries. Let's say the table you want to insert or update looks like this:
TABLE original id integer, value char(100)
first you can create a temporary table with new values ββ(you can use SELECT INTO or other ways to create it)
TABLE temp id integer, value char(100)
now you need to do two things, update the lines in the original, and then insert the new values
UPDATE original SET original.value = temp.value FROM original, temp WHERE original.id = temp.id INSERT INTO original SELECT * from temp WHERE temp.id not IN (select o.id from original o)
Andrea Bertani
source share