ERROR: plan should not reference subplan's variable - Mailing list pgsql-sql

From Catalin Pitis
Subject ERROR: plan should not reference subplan's variable
Date
Msg-id 63c4c13c0605021213t4a3d5591m2a62dd3389009bb0@mail.gmail.com
Whole thread Raw
Responses Re: ERROR: plan should not reference subplan's variable
Re: ERROR: plan should not reference subplan's variable
List pgsql-sql
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

pgsql-sql by date:

Previous
From: Jorge Godoy
Date:
Subject: Creating nested functions with plpgsql
Next
From: Tom Lane
Date:
Subject: Re: ERROR: plan should not reference subplan's variable