Thread: "Relation does not exist" error

"Relation does not exist" error

From
Tuckheng
Date:
Hi,

I encountered this error when trying to run a SELECT statement from within a
Perl program. Would appreciate if someone could help shed some light on what
may be causing this or how it can be resolved.

I have tried the exact same program on an older version of Linux (I believe
ver 6.x) and it works fine. The current Linux version is 7.x. Not sure if
the difference in version has any significance.

Have tried re-starting the Postgresql DB as well as the server itself but no
help.

Error is as below: (statement in blue is the SQL command constructed)
DBD::Pg::st execute failed: ERROR: Relation 'p' does not exist Please
contact system administrator SELECT s.siteaname, p.siteid, s.sitestatus,
p.probclass, p.duration, p.down, p.penalty, p.projid, p.custname,
p.servicetype from problemlog p, sitedetails s where p.custid = s.custid and
p.siteid = s.siteid and p.projid = s.projid and p.logstatus = 'Closed' and
upper(p.custid) like '%AIA%' union SELECT s.siteaname, p.siteid,
s.sitestatus, p.probclass, age(p.probresdatetime,p.probstadatetime),
age(p.servrestdatetime, p.probstadatetime),
age(p.servrestdatetime,p.probstadatetime),p.projid, p.custname,
p.servicetype from problemlog p, sitedetails s where p.custid = s.custid and
p.siteid = s.siteid and p.projid = s.projid and p.logstatus != 'Closed' and
upper(p.custid) like '%AIA%' order by p.projid, p.siteid, s.siteaname


Regards,
Tuck Heng
VADS BHD
03 - 7712 8330


Re: "Relation does not exist" error

From
Tom Lane
Date:
Tuckheng <Tuckheng@vads.com> writes:
> I encountered this error when trying to run a SELECT statement from within a
> Perl program. Would appreciate if someone could help shed some light on what
> may be causing this or how it can be resolved.

ORDER BY on a UNION result can only refer to column names of the UNION
output columns.  Lose the "p." and "s." in the ORDER BY and you'll be
fine.

            regards, tom lane

Re: "Relation does not exist" error

From
Tuckheng
Date:
Hi,

Thanks a bundle. Applied your suggestion and it works :-)

Regards,
Tuck Heng
VADS BHD
03 - 7712 8330


-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Thursday, November 08, 2001 10:35 PM
To: Tuckheng
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] "Relation does not exist" error


Tuckheng <Tuckheng@vads.com> writes:
> I encountered this error when trying to run a SELECT statement from within
a
> Perl program. Would appreciate if someone could help shed some light on
what
> may be causing this or how it can be resolved.

ORDER BY on a UNION result can only refer to column names of the UNION
output columns.  Lose the "p." and "s." in the ORDER BY and you'll be
fine.

            regards, tom lane