Re: What about SELECT INTO in EXECUTE - Mailing list pgsql-general

From Richard Huxton
Subject Re: What about SELECT INTO in EXECUTE
Date
Msg-id 200303051843.22139.dev@archonet.com
Whole thread Raw
In response to Re: What about SELECT INTO in EXECUTE  (Ivan <iv@psycho.pl>)
List pgsql-general
On Wednesday 05 Mar 2003 5:10 pm, Ivan wrote:
> but its not SQL error but just in plpgsql ,
> SELECT INTO same_var sth from table;
> I can not write EXECUTE ''SELECT INTO same_var sth from table;'';
> because SELECT INTO not work with EXECUTE , so what can i do else ?

Ah, sorry, I see what you're trying to do now.

You're quite right, the SELECT INTO <plpgsql-variable> construct only works
within plpgsql, whereas EXECUTE runs standard SQL.

The solution is to use the FOR ... IN ... EXECUTE loop structure (even if you
only want one row) - see the manual section on plpgsql control structures
(programmers guide) for details. This is a known limitation of the EXECUTE
command and is mentioned in the relevant section, but perhaps not clearly
enough.

HTH

--
  Richard Huxton

pgsql-general by date:

Previous
From: Medi Montaseri
Date:
Subject: Re: Why PostgreSQL?
Next
From: Richard Huxton
Date:
Subject: Re: a date_part question