Re: Using Temporary Tables in postgres functions

From: Mario Splivalo <mario(dot)splivalo(at)mobart(dot)hr>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Using Temporary Tables in postgres functions
Date: 2007-01-26 10:47:05
Message-ID: 1169808425.3045.15.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, 2007-01-25 at 11:00 -0500, Andrew Sullivan wrote:
> 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.

Yes, I'm well aware of that, and learned to live with it :) The only
drawback is that my plpgsql code looks realy uqly, because of the
creation of the string variables containing the actuall SQL code that
deals with the temporary tables used. Therefore I'm trying not to use
temp tables as much as I can. A table-type variables would be realy nice
thing to have, I guess they would exist only in memory, and for some
complicated OLTP stuff those could be realy realy hand.

Just a wish, in a way :)

Mike

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Mario Splivalo 2007-01-26 10:51:45 Re: Using Temporary Tables in postgres functions
Previous Message Mario Splivalo 2007-01-26 10:46:37 Re: Using Temporary Tables in postgres functions