X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6E292D6E84 for ; Tue, 23 Aug 2005 11:07:07 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90520-08 for ; Tue, 23 Aug 2005 14:07:05 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id D2668D6EB2 for ; Tue, 23 Aug 2005 11:07:02 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7NE6tKf002024; Tue, 23 Aug 2005 10:06:55 -0400 (EDT) To: neil.saunders@accenture.com Cc: pgsql-sql@postgresql.org Subject: Re: Problem calling stored procedure In-reply-to: References: Comments: In-reply-to message dated "Tue, 23 Aug 2005 11:33:40 +0200" Date: Tue, 23 Aug 2005 10:06:55 -0400 Message-ID: <2023.1124806015@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200508/204 X-Sequence-Number: 22432 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