Re: Using SELECT IN with prepared statement

Поиск
Список
Период
Сортировка
От Guillaume Cottenceau
Тема Re: Using SELECT IN with prepared statement
Дата
Msg-id 87abc6ck5j.fsf@mnc.ch
обсуждение исходный текст
Ответ на Re: Using SELECT IN with prepared statement  (Ingmar Lötzsch <iloetzsch@asci-systemhaus.de>)
Ответы Re: Using SELECT IN with prepared statement  (Ingmar Lötzsch <iloetzsch@asci-systemhaus.de>)
Список pgsql-jdbc
Ingmar Lötzsch <iloetzsch 'at' asci-systemhaus.de> writes:

> Of course you can concatenate the values like
>
> String idlist = "1, 2";
> String sql = "SELECT" + ... + "WHERE id IN (" + idlist + ")";
>
> and execute the statement. But there is no parameter.

...which is not too good, as the driver escapes/sanitizes input
much better than us (e.g. using parameters is *good*). Hence
personally, from JDBC, I like this workaround:

SELECT * FROM pg_language WHERE lanname = ANY( string_to_array(?, ',') );

See:

http://zarb.org/~gc/html/doc-misc.html#2008-08-21

--
Guillaume Cottenceau

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

Предыдущее
От: Ingmar Lötzsch
Дата:
Сообщение: Re: Using SELECT IN with prepared statement
Следующее
От: Ingmar Lötzsch
Дата:
Сообщение: Re: Using SELECT IN with prepared statement