From: | Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> |
---|---|
To: | Janek Sendrowski <janek12(at)web(dot)de> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: store multiple rows with the SELECT INTO statement |
Date: | 2013-09-02 00:59:47 |
Message-ID: | 5223E303.9070704@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(dot)klaver(at)gmail(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | 高健 | 2013-09-02 01:25:43 | Re: My Experiment of PG crash when dealing with huge amount of data |
Previous Message | Janek Sendrowski | 2013-09-02 00:23:59 | store multiple rows with the SELECT INTO statement |