Alternative to temp tables?

From: Postgres User <postgres(dot)developer(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Alternative to temp tables?
Date: 2009-09-12 06:51:40
Message-ID: b88c3460909112351m60b7782bod7fdd5d00e79505@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I have a simple function that returns a set of rows:

CREATE OR REPLACE FUNCTION foo()
RETURNS SETOF record AS
$$
BEGIN
RETURN QUERY SELECT * FROM people WHERE last_name = 'jones';
END
$$
LANGUAGE 'plpgsql'

In a separate function, I call the function and store the results in a
temp table using this syntax:

INSERT INTO tmp_tbl SELECT * FROM foo()

This works, but I'd like to know if there's another way to hold the
results. Can I get the results from foo() and store those in a local
var such as

recs record[] OR
recs people[]

Or are temp tables the only way to hold table-based results?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2009-09-12 06:58:30 Re: Alternative to temp tables?
Previous Message Vikram Patil 2009-09-12 03:23:58 Regarding initdb & pg_ctl