EXECUTE with SELECT INTO variable, or alternatives

Поиск
Список
Период
Сортировка
От Mario Splivalo
Тема EXECUTE with SELECT INTO variable, or alternatives
Дата
Msg-id 1128017805.9061.5.camel@localhost.localdomain
обсуждение исходный текст
Ответы Re: EXECUTE with SELECT INTO variable, or alternatives
Список pgsql-sql
I can assign a value to a variable in several ways:

myVar := (SELECT col FROM table WHERE somecondition...)
myVar := col FROM table WHERE somecondtition...
SELECT col INTO myVar FROM table WHERE somecondition

How do I do any of the above using EXECUTE? I need to be able to assign
the value to a variable, a value returned by a querry on a temporary
table.

So far I have found workaround like this:

myRec record;

FOR rec IN EXECUTE ''SELECT col FROM table WHERE somecondition''
LOOPmyVar := rec
END LOOP

Obviously, the above SELECT query returns only one row. Still, if is
realy inconvinient to have FOR...LOOP...END LOOP construct for assigning
the value to a variable 'read' from the temporary table.
Mario



В списке pgsql-sql по дате отправления: