| From: | Rémi Aubel <remi(dot)aubel(at)gmail(dot)com> |
|---|---|
| To: | pgsql-jdbc(at)postgresql(dot)org |
| Subject: | "could not determine data type of parameter" with timestamp |
| Date: | 2017-12-05 15:11:35 |
| Message-ID: | CAG2M1febgZbhBwm0DQK4Y5ekDrTbzTyAa1syKcdXw+6Y8caK4g@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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.
--
| From | Date | Subject | |
|---|---|---|---|
| Next Message | rob stone | 2017-12-05 20:22:15 | Re: "could not determine data type of parameter" with timestamp |
| Previous Message | Michael Paquier | 2017-12-01 02:11:14 | Re: [JDBC] [HACKERS] Channel binding support for SCRAM-SHA-256 |