Re: creating a temp table in a function

From: Andreas 'ads' Scherbaum <adsmail(at)wars-nicht(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: creating a temp table in a function
Date: 2008-04-04 19:47:18
Message-ID: 20080404214718.734025bf@iridium.wars-nicht.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 4 Apr 2008 09:13:18 -0700 Shahaf Abileah wrote:

> I have a function that creates a temp table and drops it on commit. If
> I run the function twice in the same psql interactive session, I get an
> error. If I run it twice in two different psql sessions (using the -c
> flag), I get no error. Is this expected behavior? If so, why?

Create a query in a text string and run the query with EXECUTE.

In your case the OIDs are determined during parsing, but in the next
function call the temp table is gone away. So you have to make sure the
table is dynamically created.

Kind regards

--
Andreas 'ads' Scherbaum
German PostgreSQL User Group
European PostgreSQL User Group - Board of Directors

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ivan Sergio Borgonovo 2008-04-04 19:53:57 Re: creating a temp table in a function
Previous Message Rusty Conover 2008-04-04 19:42:36 pg_dump and schemas