Обсуждение: What about SELECT INTO in EXECUTE
when in plpgsql i do EXECUTE ''SELECT INTO foo 4 ''; its not implemented yet, so when ?
On Tuesday 04 Mar 2003 8:30 pm, Ivan wrote: > when in plpgsql i do EXECUTE ''SELECT INTO foo 4 ''; its not implemented > yet, so when ? I don't think this is valid SQL - should it not be "SELECT 4 INTO foo"? -- Richard Huxton
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 ? On Wed, 5 Mar 2003, Richard Huxton wrote: > On Tuesday 04 Mar 2003 8:30 pm, Ivan wrote: > > when in plpgsql i do EXECUTE ''SELECT INTO foo 4 ''; its not implemented > > yet, so when ? > > I don't think this is valid SQL - should it not be "SELECT 4 INTO foo"? > -- > Richard Huxton > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) >
I guess one solution is to insert into a temporary table in the EXECUTE
statement...
Then execute a SQL query (without EXECUTE) to get the value into the
variable.
I use to do like that with MS SQL Server as there is no other solution...
Hope it helps
----------------------------------------------------------------------------
---------------
Patrick Fiche
email : patrick.fiche@aqsacom.com
tél : 01 69 29 36 18
----------------------------------------------------------------------------
---------------
-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org]On Behalf Of Ivan
Sent: Wednesday, March 05, 2003 6:11 PM
To: Richard Huxton
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] What about SELECT INTO in EXECUTE
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 ?
On Wed, 5 Mar 2003, Richard Huxton wrote:
> On Tuesday 04 Mar 2003 8:30 pm, Ivan wrote:
> > when in plpgsql i do EXECUTE ''SELECT INTO foo 4 ''; its not implemented
> > yet, so when ?
>
> I don't think this is valid SQL - should it not be "SELECT 4 INTO foo"?
> --
> Richard Huxton
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
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