Alias-Error

Started by Jost Richsteinover 22 years ago5 messagesgeneral
Jump to latest
#1Jost Richstein
jrichstein@softdecc.com

Hi,

I am running a query with alias (a self join) against
version 7.3.4 on Suse Linux 7.3 and on FreeBSD (v5?).
It runs fine on Linux, but produces an error on
FreeBSD: "unknown alias C2". And btw: the query runs
on every other DB I have tried...

The Query is something like this:

SELECT DISTINCT C2.cmc_mchap, C2.cmc_sort
FROM sis_cmca, sis_cmca C2
WHERE cm_status != 'U' AND sis_cmca.cmc_name='INTERN2000' AND
C2.cmc_name='INTERN2000' AND sis_cmca.cmc_mchap=C2.cmc_mchap
....

What causes this error? Workarounds?

Jost

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jost Richstein (#1)
Re: Alias-Error

Jost Richstein <jrichstein@softdecc.com> writes:

I am running a query with alias (a self join) against
version 7.3.4 on Suse Linux 7.3 and on FreeBSD (v5?).
It runs fine on Linux, but produces an error on
FreeBSD: "unknown alias C2".

The string "unknown alias" appears nowhere in the 7.3 sources.
Are you sure you are talking to a Postgres database?

regards, tom lane

#3Jost Richstein
jrichstein@softdecc.com
In reply to: Jost Richstein (#1)
Re: Alias-Error

Ok. The exact error message is as follows:

SQLException Time : Mon Oct 20 13:15:25 CEST 2003
SQLException ErrorCode : 0
SQLException SQLState : null
SQLException Message : ERROR: Relation "c2" does not exist
SQLException Connection: 4878867

The query is something like this:

SELECT DISTINCT C2.cmc_mchap, C2.cmc_sort
FROM sis_cmca, sis_cmca C2
WHERE cm_status != 'U' AND sis_cmca.cmc_name='INTERN2000' AND
C2.cmc_name='INTERN2000' AND sis_cmca.cmc_mchap=C2.cmc_mchap

Tom Lane wrote:

Show quoted text

Jost Richstein <jrichstein@softdecc.com> writes:

I am running a query with alias (a self join) against
version 7.3.4 on Suse Linux 7.3 and on FreeBSD (v5?).
It runs fine on Linux, but produces an error on
FreeBSD: "unknown alias C2".

The string "unknown alias" appears nowhere in the 7.3 sources.
Are you sure you are talking to a Postgres database?

regards, tom lane

#4Richard Huxton
dev@archonet.com
In reply to: Jost Richstein (#3)
Re: [SQL] Alias-Error

On Tuesday 21 October 2003 08:17, Jost Richstein wrote:

Ok. The exact error message is as follows:

SQLException Time : Mon Oct 20 13:15:25 CEST 2003
SQLException ErrorCode : 0
SQLException SQLState : null
SQLException Message : ERROR: Relation "c2" does not exist
SQLException Connection: 4878867

The query is something like this:

SELECT DISTINCT C2.cmc_mchap, C2.cmc_sort
FROM sis_cmca, sis_cmca C2
WHERE cm_status != 'U' AND sis_cmca.cmc_name='INTERN2000' AND

^^^^^^^^^
You're missing a table name here. It could be PG is reporting the wrong error.

C2.cmc_name='INTERN2000' AND sis_cmca.cmc_mchap=C2.cmc_mchap

--
Richard Huxton
Archonet Ltd

#5Csaba Nagy
nagy@ecircle-ag.com
In reply to: Jost Richstein (#3)
Re: Alias-Error

You have the alias in upper case: "C2", and postgres complains about a
lower case "c2". May be this some case sensitivity problem ?
Just a thought.

HTH,
Csaba.

Show quoted text

On Tue, 2003-10-21 at 09:17, Jost Richstein wrote:

Ok. The exact error message is as follows:

SQLException Time : Mon Oct 20 13:15:25 CEST 2003
SQLException ErrorCode : 0
SQLException SQLState : null
SQLException Message : ERROR: Relation "c2" does not exist
SQLException Connection: 4878867

The query is something like this:

SELECT DISTINCT C2.cmc_mchap, C2.cmc_sort
FROM sis_cmca, sis_cmca C2
WHERE cm_status != 'U' AND sis_cmca.cmc_name='INTERN2000' AND
C2.cmc_name='INTERN2000' AND sis_cmca.cmc_mchap=C2.cmc_mchap

Tom Lane wrote:

Jost Richstein <jrichstein@softdecc.com> writes:

I am running a query with alias (a self join) against
version 7.3.4 on Suse Linux 7.3 and on FreeBSD (v5?).
It runs fine on Linux, but produces an error on
FreeBSD: "unknown alias C2".

The string "unknown alias" appears nowhere in the 7.3 sources.
Are you sure you are talking to a Postgres database?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html