Re: ANY subquery and PreparedStatements

Поиск
Список
Период
Сортировка
От David Wall
Тема Re: ANY subquery and PreparedStatements
Дата
Msg-id 001e01c2d842$7bed8500$3201a8c0@expertrade.com
обсуждение исходный текст
Ответ на ANY subquery and PreparedStatements  (Felipe Schnack <felipes@ritterdosreis.br>)
Ответы Re: ANY subquery and PreparedStatements
Re: ANY subquery and PreparedStatements
Список pgsql-jdbc
>   You're right... but it's actually based on user interaction (i.e.:
> selecting items using checkboxes)
>   I guess I'll just have to issue a query per item... ugly :-(

Why can't you simply build the prepared statement on the fly based on the
number of values to be placed in the IN list?  If you have 3 items, you just
append three '?' and if you have 20 items, then you append 20 '?' to your
list.  This way the number of '?' will match the number of
PreparedStatement.setXXX() calls and you don't have to rely on the database
handling all the nulls.  Since the list is fairly dynamic anyway, it's
overall performance will be about the same (and it's much better than doing
a series of queries instead).

Of course, there are limits on how long a query can be for most databases,
so you may find that if the list is too long, you'll run into query
processor problems.

David


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

Предыдущее
От: "Dirk Bromberg"
Дата:
Сообщение: Priority of Statments / Connections
Следующее
От: "Nagy Istvan"
Дата:
Сообщение: Re: SSL for JDBC