Thread: plpgsql select into with multiple target variables

plpgsql select into with multiple target variables

From
John DeSoi
Date:
The docs say:

The result of a SELECT command yielding multiple columns (but  only one 
row) can be assigned to a record variable, row-type  variable, or list 
of scalar variables. This is done by:
SELECT INTO target  select_expressions  FROM ...;
where target can be a record variable, a row  variable, or a 
comma-separated list of simple variables and  record/row fields. The 
select_expressions  and the remainder of the command are the same as in 
regular SQL.

So, I'm trying to do the "list of scalar variables" target, but I can't 
get the syntax right. Something like

SELECT into varx, vary, varz,  colx, coly, colz, FROM ....

I've tried parens and various other things but no luck.


John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL



Re: plpgsql select into with multiple target variables

From
PFC
Date:
Try removing the comma after varz

> SELECT into varx, vary, varz,
>    colx, coly, colz, FROM ....
>
> I've tried parens and various other things but no luck.
>
>
> John DeSoi, Ph.D.
> http://pgedit.com/
> Power Tools for PostgreSQL
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
>                http://archives.postgresql.org
>