Re: Using Temporary Tables in postgres functions

From: Mario Splivalo <mario(dot)splivalo(at)mobart(dot)hr>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Using Temporary Tables in postgres functions
Date: 2007-01-26 10:51:45
Message-ID: 1169808705.3045.21.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, 2007-01-25 at 11:09 -0500, Tom Lane wrote:
> Mario Splivalo <mario(dot)splivalo(at)mobart(dot)hr> writes:
> > Am I doing something wrong here, or there is no way of using temporary
> > tables within 'sql' written functions?
>
> I believe the problem is that for a SQL function we parse the whole
> function body before executing any of it. So you'd need to split this
> into two separate functions.

Having two function complicates, a bit, interface between applicaation
and the database. But, then again, If I split it in two functions, then
one with the UPDATE still can't find temp table referenced in other
function, right?

I have no problem writing func1() example in plpgsql, it just seemed to
me that using sql instead of plpgsql (when I actually can use sql) gives
me a little performance improvement.

Mike

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Luís Sousa 2007-01-26 11:58:24 Evaluate a variable
Previous Message Mario Splivalo 2007-01-26 10:47:05 Re: Using Temporary Tables in postgres functions