Re: prepare in a do loop

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: prepare in a do loop
Дата
Msg-id 3d94209d-b100-0f07-e2b0-213d4467e870@aklaver.com
обсуждение исходный текст
Ответ на Re: prepare in a do loop  (Marc Millas <marc.millas@mokadb.com>)
Список pgsql-general
On 2/15/21 9:55 AM, Marc Millas wrote:
> Hi Tom,
> 
> I do read the doc, and understand the caching behaviour of plpgsql.

This is not about plpgsql caching. It is about EXECUTE in plpgsql 
meaning something different then the PREPARE/EXECUTE combination in SQL. 
  You are trying to run EXECUTE moninsert(randname()) in plpgsql where 
moninsert was a PREPARE statement. In plpgsql EXECUTE is something 
different so it does not recognize  moninsert(randname()) as a prepared 
statement and fails.



> if in psql I write begin;execute moninsert(randname()); execute 
> moninsert(randname());end;
> it does work.  And if I put this (begin execute end) inside a do loop it 
> doesnt anymore.
> ok the begin execute end is ""pure"" SQL, and the same thing within a do 
> loop is plpgsql
> so
> postgres=# create function testexec()returns void as $$
> postgres$# execute moninsert(randname());
> postgres$# end;
> postgres$# $$ language plpgsql;
> ERREUR:  erreur de syntaxe sur ou près de « execute »
> LIGNE 2 : execute moninsert(randname());
> fine, quite coherent.
> then




-- 
Adrian Klaver
adrian.klaver@aklaver.com



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