incomplete CTE declaration and "column reference x is ambiguous"

From: Marc Mamin <M(dot)Mamin(at)intershop(dot)de>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: incomplete CTE declaration and "column reference x is ambiguous"
Date: 2013-07-01 14:49:57
Message-ID: B6F6FD62F2624C4C9916AC0175D56D880CE0135F@jenmbs01.ad.intershop.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I've lost some time to debug a large Query with many CTE.
I couldn't really believe the error message.

it was correct after all , though surprising.
a short version to illustrate my error:

WITH t1 (a,b) AS (
SELECT
1 as x,
2 as a,
3 as b
)
select * from t1 WHERE b =0

ERROR: column reference "b" is ambiguous.

It would be nice, if extra undeclared columns would not be visible outside the CTE.

regards,

Marc Mamin

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Orlitzky 2013-07-01 15:05:11 Re: (Default) Group permissions
Previous Message Andrew Sullivan 2013-07-01 14:21:45 Re: (Default) Group permissions