Re: Problem with the semantics of "select into" in a plpgsql function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Seref Arikan <serefarikan(at)kurumsalteknoloji(dot)com>
Cc: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Problem with the semantics of "select into" in a plpgsql function
Date: 2012-12-25 18:37:50
Message-ID: 23224.1356460670@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Seref Arikan <serefarikan(at)kurumsalteknoloji(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Seref Arikan 2012-12-25 18:56:31 Re: Problem with the semantics of "select into" in a plpgsql function
Previous Message Philipp Kraus 2012-12-25 18:17:23 Re: logger table