Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id D48CE9FB64F for ; Thu, 25 Jan 2007 12:01:02 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 39825-06 for ; Thu, 25 Jan 2007 12:00:52 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id D034A9FB651 for ; Thu, 25 Jan 2007 12:00:51 -0400 (AST) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1HA7Cc-0002Eo-Vq for pgsql-sql@postgresql.org; Thu, 25 Jan 2007 11:11:55 -0500 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id A3BA54051; Thu, 25 Jan 2007 11:00:38 -0500 (EST) Date: Thu, 25 Jan 2007 11:00:38 -0500 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Using Temporary Tables in postgres functions Message-ID: <20070125160038.GB16529@phlogiston.dyndns.org> References: <1169735954.31872.38.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1169735954.31872.38.camel@localhost.localdomain> User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/119 X-Sequence-Number: 27271 On Thu, Jan 25, 2007 at 03:39:14PM +0100, Mario Splivalo wrote: > When I try to use TEMPORARY TABLE within postgres functions (using 'sql' > as a function language), I can't because postgres can't find that > temporary table. Consider this example: You need to build the temp table and EXECUTE the statement. The problem is that the plan is cached for later re-use. Since the cached plan has the id of a table that no longer exists, you get this error. See the PL/pgSQL part of the manual for more on this. A -- Andrew Sullivan | ajs@crankycanuck.ca Unfortunately reformatting the Internet is a little more painful than reformatting your hard drive when it gets out of whack. --Scott Morris