Re: store multiple rows with the SELECT INTO statement - Mailing list pgsql-general

From Adrian Klaver
Subject Re: store multiple rows with the SELECT INTO statement
Date
Msg-id 5223E303.9070704@gmail.com
Whole thread Raw
In response to store multiple rows with the SELECT INTO statement  ("Janek Sendrowski" <janek12@web.de>)
List pgsql-general
On 09/01/2013 05:23 PM, Janek Sendrowski wrote:
> Hi,
> Why is it only possible to store one row by a query which returns
> multiple rows using the SELECT INTO statement.
> and
> How can I do a Query on a record varialbe, somehow like this:
> SELECT * FROM v_rec

You can't a record variable can only hold a single row.

FYI SELECT INTO in plpgsql is not the same as the SQL SELECT INTO:

http://www.postgresql.org/docs/9.2/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-SQL-ONEROW

Tip: Note that this interpretation of SELECT with INTO is quite
different from PostgreSQL's regular SELECT INTO command, wherein the
INTO target is a newly created table. If you want to create a table from
a SELECT result inside a PL/pgSQL function, use the syntax CREATE TABLE
... AS SELECT.

One way I have gotten around this to create a temporary table in the
function and fill it with data and then select from it as suggested above.

> Janek Sendrowski


--
Adrian Klaver
adrian.klaver@gmail.com


pgsql-general by date:

Previous
From: "Janek Sendrowski"
Date:
Subject: store multiple rows with the SELECT INTO statement
Next
From: 高健
Date:
Subject: Re: My Experiment of PG crash when dealing with huge amount of data