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

From: "David Johnston" <polobo(at)yahoo(dot)com>
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 16:26:00
Message-ID: 003401cde2bc$8740eac0$95c2c040$@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"SELECT INTO -- define a new table from the results of a query"

If the table exists use:

INSERT INTO tbl (.) SELECT .

David J.

From: Seref Arikan [mailto:serefarikan(at)kurumsalteknoloji(dot)com]
Sent: Tuesday, December 25, 2012 10:52 AM
To: David Johnston
Cc: PG-General Mailing List
Subject: Re: [GENERAL] Problem with the semantics of "select into" in a
plpgsql function

David,
Thanks for your response. However, I can't see my solution there. According
to documentation, select into is supposed to create a new table. "Create
table as " is offered as an alternative, but my table is already ready when
I execute the statement.
Maybe it is my lack of understanding, but I can't see how the documentation
helps to use eav_temp_table as a table name, rather than a variable.

On Tue, Dec 25, 2012 at 3:39 PM, David Johnston <polobo(at)yahoo(dot)com> wrote:

The documentation for "select into" covers this and provides your
alternatives.

http://www.postgresql.org/docs/9.2/interactive/sql-selectinto.html

David J.

On Dec 25, 2012, at 10:20, Seref Arikan <serefarikan(at)kurumsalteknoloji(dot)com>
wrote:

> Greetings,
> I have a plpython function that returns a set of records. I loop over them
to insert them into a temp table created by another function.
> I wanted to test
> select into temp_eav_table (column) select a.column from tbl as a
where....
> approach to see if it performs better than the loop. However, I'm not able
to compile the function due to an error that says "temp_eav_table is not a
known variable"
>
> So the context assumes this is supposed to be a variable. If I try execute
'...', then I have trouble passing a bytea parameter to the python function.
This is what I have at the moment:
>
> 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;
>
> any thoughts?
>
> Best regards
> Seref
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2012-12-25 16:32:29 Re: check user in group
Previous Message Jason Dusek 2012-12-25 16:19:31 Re: logger table