Re: What about SELECT INTO in EXECUTE

From: Richard Huxton <dev(at)archonet(dot)com>
To: Ivan <iv(at)psycho(dot)pl>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: What about SELECT INTO in EXECUTE
Date: 2003-03-05 18:43:21
Message-ID: 200303051843.22139.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Medi Montaseri 2003-03-05 18:47:37 Re: Why PostgreSQL?
Previous Message Andrew Sullivan 2003-03-05 18:11:02 Re: pg_ctl -m fast failing?