Re: prepared statement already exists

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: prepared statement already exists
Дата
Msg-id 20060814152948.GA93423@winnie.fuhr.org
обсуждение исходный текст
Ответ на prepared statement already exists  (Jim Bryan <gooddayarizona@yahoo.com>)
Список pgsql-general
On Sun, Aug 13, 2006 at 10:48:37AM -0700, Jim Bryan wrote:
> Hi!  In a function to insert rows into a table, I keep
> getting ERROR: prepared statement "updateplan" already
> exists.  If any ideas; thanks.

As the error says, you already have a prepared statement named
"updateplan".  To reuse that name you'll need to DEALLOCATE it
first.  However, then you'll get the following error:

test=> SELECT testPreparedStatement();
ERROR:  function updateplan(integer, integer) does not exist

That's because the PL/pgSQL command EXECUTE is different than the
SQL command EXECUTE:

http://www.postgresql.org/docs/8.1/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN

You don't need to use prepared statements in PL/pgSQL functions
because the language automatically prepares and caches query plans.
Just do the INSERT directly.

--
Michael Fuhr

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

Предыдущее
От: AgentM
Дата:
Сообщение: Re: Best approach for a "gap-less" sequence
Следующее
От: Jorge Godoy
Дата:
Сообщение: Re: Best approach for a "gap-less" sequence