Search Postgresql Archives

Re: store multiple rows with the SELECT INTO statement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux