What is PG best practice for storing temporary data in functions?

From: "Ben" <ben(at)kappia(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: What is PG best practice for storing temporary data in functions?
Date: 2004-07-05 12:29:52
Message-ID: 014601c4628b$c651c3c0$0500a8c0@asus
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

There is a very common technique used in other RDBMS (e.g. Sybase)
stored procedure programming which I am not sure how best to replicate
in Postgres functions.

A Sybase stored procedure can do
select <some complex query> into #temp1
create table #temp2 (.)
call some proc which also uses #temp1 and #temp2
etc

where #temp1 and #temp2 are temporary tables magically created by the
server for the duration of the procedure call only (the procedure can be
safely executed in parallel since each execution sees only its own
data). Under the hood, it does this by mangling the names of the temp
tables with a unique identifier for the procedure context.

What are the cleanest and most performant ways to do this in Postgres
(7.4.2)? I am aware of temporary tables but they are globally visible to
other invocations in the same session. We need the equivalent of local
method variables I guess.


Browse pgsql-sql by date

  From Date Subject
Next Message Markus Bertheau 2004-07-05 15:31:36 Custom type where not all elements are comparable
Previous Message Richard Huxton 2004-07-05 11:34:04 Re: Why no exprs in format string to RAISE