Re: Newbie question: returning rowtypes from a plpgsql function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Larry White <ljw1001(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Newbie question: returning rowtypes from a plpgsql function
Date: 2004-12-01 15:05:51
Message-ID: 7928.1101913551@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Larry White <ljw1001(at)gmail(dot)com> writes:
> mysql> create table t as ( select * from table_x);

That works in Postgres too. The SELECT INTO construct is a bit broken
since, as you discovered, it has a different meaning in plpgsql than
in the main SQL language. So I recommend using CREATE TABLE AS when
you want to create a table this way.

> The declarations section of the pl/pgsql documentation doesn't explain
> how to declare a variable to represent a set of rows

You can't. Possibly a cursor would help?

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Riccardo G. Facchini 2004-12-01 15:19:17 Re: [PERFORM] pg_restore taking 4 hours!
Previous Message Bruno Wolff III 2004-12-01 14:45:30 Re: [HACKERS] Adding Reply-To: <listname> to Lists configuration ...