I have a PostgreSQL database and I want to make a script that replaces the data of one column of the table A with the data of an other tables column. I've written this PL/PgSQL function:
BEGIN;
CREATE TEMPORARY TABLE tmp_table (id bigint PRIMARY KEY,
registrationnumber character varying(255));
INSERT INTO tmp_table
select id,registrationnumber from tableB;
for d in tmp_table loop
update TABLEA set registrationnumber=d.id where
registrationnumber=d.registrationnumber;
return next d;
end loop;
END;
What is going wrong with my script?