Re: Server side prepared statements and executemany

Поиск
Список
Период
Сортировка
От Federico Di Gregorio
Тема Re: Server side prepared statements and executemany
Дата
Msg-id 52861CDE.7010601@dndg.it
обсуждение исходный текст
Ответ на Re: Server side prepared statements and executemany  (Luca Ferroni <luca@befair.it>)
Список psycopg
On 15/11/2013 13:34, Luca Ferroni wrote:
> you are right, here is the example. In writing it I noticed an
> interesting behaviour.
> Prepared statements work with query like:
>
> prepare psyco_1 as SELECT * FROM "prova" WHERE "name" = $1
>
> but they raise ProgrammingError (syntaxerror SQL) with the operator IN
>
> prepare psyco_1 as SELECT * FROM "prova" WHERE "name" IN $1

IN has always had problems, not just when used thorugh psycopg. My
suggestion is to substitute it with ANY:


prepare psyco_1 as SELECT * FROM "prova" WHERE "name" = ANY($1).

Note that $1 should be an array (but isn't a problem when using psycopg,
just pass a list).

federico

--
Federico Di Gregorio                         federico.digregorio@dndg.it
Di Nunzio & Di Gregorio srl                               http://dndg.it
 If a process is potentially good, but 90%+ of the time smart and
  well-intentioned people screw it up, then it's a bad process.
                                                          -- Steve Yegge


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

Предыдущее
От: Joe Abbate
Дата:
Сообщение: Re: Server side prepared statements and executemany
Следующее
От: jared
Дата:
Сообщение: Value substitutions with a dictionary.