I run the following script to export some data from my development
database and then update or insert the records into to the quality
assurance testing database, but I get a warning notice that I don't
understand. Aside from that notice, the script appears to work as
intended, i.e., updating existing report definitions and adding any new
ones defined in the dev environment but not appearing in QAT.
Here is the script:
\set ON_ERROR_STOP ON
COPY report TO '/home/postgres/report.sql';
\c paidqat
CREATE TEMPORARY TABLE temptable AS SELECT * FROM report;
DELETE FROM temptable;
COPY temptable FROM '/home/postgres/report.sql';
UPDATE report SET resource = (
SELECT resource FROM temptable s1
WHERE s1.title = report.title)
WHERE EXISTS(SELECT 1 FROM temptable s1
WHERE s1.title = report.title);
INSERT INTO report (
SELECT * FROM temptable s1 EXCEPT
SELECT * FROM report s2 WHERE s2.title = report.title);
The warning notice refers to the last command in the script, i.e., the
INSERT, but inserts do occur successfully as a result.
Here is the run and the resulting notice message:
bash-2.05a$ psql -f urep.sql -U paid paiddev
COPY
You are now connected to database paidqat.
SELECT
DELETE 6
COPY
UPDATE 6
psql:urep.sql:20: NOTICE: Adding missing FROM-clause entry in subquery
for table "report"
INSERT 0 1
bash-2.05a$
~Berend Tober