Re: [GENERAL] Fwd: Query parameter types not recognized

Поиск
Список
Период
Сортировка
От Roberto Balarezo
Тема Re: [GENERAL] Fwd: Query parameter types not recognized
Дата
Msg-id CALN83z6yA0ssV5CqL9-s7djKnAOjo8NoVRy9npSP_ksZSFXO=A@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [GENERAL] Fwd: Query parameter types not recognized  (Arjen Nienhuis <a.g.nienhuis@gmail.com>)
Список pgsql-general
Hi Arjen,

I already tried that too. In that case, the error changes to `org.postgresql.util.PSQLException: ERROR: COALESCE types timestamp without time zone and interval cannot be matched`.

I listed all the operators available for dates, and `+` and `-` take a date and an integer to return a date with one day added. So the query is correct.

2017-02-10 16:33 GMT-05:00 Arjen Nienhuis <a.g.nienhuis@gmail.com>:


On Feb 10, 2017 8:11 PM, "Roberto Balarezo" <rober710@gmail.com> wrote:
Hi, I would like to know why this is happening and some advice if there is a way to solve this problem:

I have a query like this:

select COALESCE(duedate, ? + 1) from invoices order by duedate desc limit 10;

where ? is a query parameter. I’m using JDBC to connect to the database, and sending parameters like this:

query.setDate(1, defaultDueDate);

If you want to add to a date you cannot just add 1. You need an interval: coalesce(duedate, ? + interval '1 day')

See:


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

Предыдущее
От: Roberto Balarezo
Дата:
Сообщение: Re: [GENERAL] Fwd: Query parameter types not recognized
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: [GENERAL] Fwd: Query parameter types not recognized