pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: neil.saunders@accenture.com
Cc: pgsql-sql@postgresql.org
Subject: Re: Problem calling stored procedure
Date: Tue, 23 Aug 2005 10:06:55 -0400
Message-ID: <2023.1124806015@sss.pgh.pa.us> (raw)
In-Reply-To: <B74B7433CDDD2C4AA41D94832E32E19D92EE94@EMEXM1112.dir.svc.accenture.com>
References: <B74B7433CDDD2C4AA41D94832E32E19D92EE94@EMEXM1112.dir.svc.accenture.com>

<neil.saunders@accenture.com> writes:
> OPEN cur_overlap FOR SELECT *, pg_class.RELNAME AS table FROM calendar_entries WHERE (start_date, end_date) OVERLAP (new_start_date, new_end_date) AND property_id = X AND pg_class.oid = tableoid;

> The only thing I can think of is that when the query runs in the psql I get:
> NOTICE: added missing FROM-clause entry for table "pg_class"

> I understand why this is happening, but don't know how I would go
> about re-writing the query to explicitly reference pg_class - I can't
> write calendar_entries.table_oid, because that changes the meaning of
> the query.

How so?  It'd be the same as far as I can see.

However, you could avoid any explicit use of pg_class by using the
regclass type instead:

OPEN cur_overlap FOR SELECT *, tableoid::regclass AS table FROM calendar_entries WHERE (start_date, end_date) OVERLAP (new_start_date, new_end_date) AND property_id = X;

As far as the reason for the difference between function execution and
manual execution: check for unintended variable substitutions.  Which
words in the query match variable names in the plpgsql function?  Are
those only the ones you intended?

			regards, tom lane



view thread (8+ messages)  latest in thread

Message-ID: <2023.1124806015@sss.pgh.pa.us>
Permalink:  ../2023.1124806015@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2023.1124806015@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, neil.saunders@accenture.com
  Subject: Re: Problem calling stored procedure
  In-Reply-To: <2023.1124806015@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox