Hi *
I'm trying to run the following SQL statement on a PostgreSQL 8.1, installed on a Windows machine:
INSERT INTO PROJECT(PROJECT_ID,PROJECT_DESC)
(
SELECT MAX(PROJECT_ID),'MYPROJECT'
FROM PROJECT
WHERE NOT EXISTS
(
SELECT PROJECT_DESC FROM PROJECT WHERE PROJECT_DESC = 'MYPROJECT'
)
)
and I get the following error:
ERROR: plan should not reference subplan's variable
If, for example, I replace MAX with some other aggregation (e.g. AVG or SUM), everything works ok.
The table DDL looks like:
CREATE TABLE project
(
project_id int4 NOT NULL,
project_desc varchar(255),
CONSTRAINT project_pkey PRIMARY KEY (project_id)
)
WITH OIDS;
Do you have any clue why does this happen?
Thanks,
Catalin