Re: Prepared statement already exists

Поиск
Список
Период
Сортировка
От Tomasz Ostrowski
Тема Re: Prepared statement already exists
Дата
Msg-id 493CC9EC.5090900@batory.org.pl
обсуждение исходный текст
Ответ на Re: Prepared statement already exists  (WireSpot <wirespot@gmail.com>)
Ответы Re: Prepared statement already exists
Список pgsql-general
On 2008-11-20 12:56, WireSpot wrote:
> On Thu, Nov 20, 2008 at 10:56, Albe Laurenz <laurenz.albe@wien.gv.at> wrote:
>> Do you still need the old prepared statement?
>>
>> If not, you can simple DEALLOCATE it and then try the PREPARE again.
>
> Yes, I'd like to keep the old statements, that's part of the perks --
> if a query will be repeated it will (possibly) benefit from the
> statement being already prepared.
>

So:

sql_md5 = md5(sql);
try {
    PREPARE sql_md5 AS sql;
} catch (SQLException e) {
    if (! e.getSQLState().equals("42P05")) {
        throw e;
    }
}
EXECUTE sql_md5;

Regards
Tometzky
--
...although Eating Honey was a very good thing to do, there was a
moment just before you began to eat it which was better than when you
were...
                                                       Winnie the Pooh

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

Предыдущее
От: "Gurjeet Singh"
Дата:
Сообщение: Re: Monty on MySQL 5.1: "Oops, we did it again"
Следующее
От: WireSpot
Дата:
Сообщение: Re: Prepared statement already exists