"could not determine data type of parameter" with timestamp
От | Rémi Aubel |
---|---|
Тема | "could not determine data type of parameter" with timestamp |
Дата | |
Msg-id | CAG2M1febgZbhBwm0DQK4Y5ekDrTbzTyAa1syKcdXw+6Y8caK4g@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: "could not determine data type of parameter" with timestamp
Re: "could not determine data type of parameter" with timestamp |
Список | pgsql-jdbc |
Hello,
I know my problem has already been answered in this list (https://www.postgresql.org/message-id/CA%2BxsaB0EMDaNek0Oky9c17_8UX3-epWVP11%2BvTNgrAPoY2s9FA%40mail.gmail.com), but it was a long time ago and I would like to know if any other solution exists now.
I need to execute this PreparedStatement:
select * from my_table where ? is null
with a bound parameter of type Timestamp.
With this form, the driver (version 42.1.4) raises this exception:
org.postgresql.util.PSQLException: ERROR: could not determine data type of parameter $1
Note: I have the same exception if the bound parameter is null. The PreparedStatement should result in
select * from my_table where null is null
which is correct SQL.
The solution given 4 years ago was to explicitly cast the parameter as a timestamp (select * from my_table where ?::timestamp is null).
But this workaround is not really useful for me, because my application uses generated (dynamic) queries and targets multiple database types (not only PosgreSQL). So, when I know the targeted database, I do not know my parameter types anymore.
Any suggestion?
Thanks in advance.
Rémi.
--
В списке pgsql-jdbc по дате отправления: