Re: Problem with the semantics of "select into" in a plpgsql function - Mailing list pgsql-general

From Tom Lane
Subject Re: Problem with the semantics of "select into" in a plpgsql function
Date
Msg-id 23224.1356460670@sss.pgh.pa.us
Whole thread Raw
In response to Problem with the semantics of "select into" in a plpgsql function  (Seref Arikan <serefarikan@kurumsalteknoloji.com>)
Responses Re: Problem with the semantics of "select into" in a plpgsql function  (Seref Arikan <serefarikan@kurumsalteknoloji.com>)
List pgsql-general
Seref Arikan <serefarikan@kurumsalteknoloji.com> writes:
> I have a plpython function that returns a set of records.

Is that actually plpython, or plpgsql?  Because what you're showing is
not legal syntax in either bare SQL or plpython, but it would act as
you're reporting in plpgsql:

> SELECT INTO temp_eav_table (valstring,
>                                     featuremappingid,
>                                     featurename,
>                                     rmtypename,
>                                     actualrmtypename,
>                                     path,
>                                     pathstring)
>     select selected_node.valstring,
>                                     selected_node.featuremappingid,
>                                     selected_node.featurename,
>                                     selected_node.rmtypename,
>                                     selected_node.actualrmtypename,
>                                     selected_node.path,
>                                     selected_node.pathstring
>     from py_get_eav_rows_from_pb(payload ) as selected_node;

SELECT INTO in plpgsql is a completely different construct than SELECT
INTO in bare SQL: the INTO target is always a local variable of the
function.  You should use CREATE TABLE AS to get the effect you're
after.  This is covered in the docs page David pointed you to, as
well as in the plpgsql documentation.

            regards, tom lane


pgsql-general by date:

Previous
From: Philipp Kraus
Date:
Subject: Re: logger table
Next
From: Seref Arikan
Date:
Subject: Re: Problem with the semantics of "select into" in a plpgsql function