Re: "could not determine data type of parameter" with timestamp
От | Rémi Aubel |
---|---|
Тема | Re: "could not determine data type of parameter" with timestamp |
Дата | |
Msg-id | CAG2M1fe7Yxaf3+iySG5PZnX13ea+Co4Qe0y4LLTjBaEPMES9kw@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: "could not determine data type of parameter" with timestamp (Dave Cramer <pg@fastcrypt.com>) |
Ответы |
Re: "could not determine data type of parameter" with timestamp
|
Список | pgsql-jdbc |
Hi,
-- Setting null for a bound value for a UUID column works fine with Dave's fix (https://github.com/pgjdbc/pgjdbc/pull/1160).
Now, I'm not able to set a null value for a timestamp.
My table:
CREATE TABLE TEST_TABLE (C_TIMESTAMP TIMESTAMP)
My query:
SELECT * FROM TEST_TABLE WHERE ? IS NULL OR ? = C_TIMESTAMP
Data type and type name for my column C_TIMESTAMP are respectively 93 and "timestamp" (checked with the metadata provided by the driver).
Using PreparedStatement.setNull(pos, 93) or PreparedStatement.setNull(pos, 93, "timestamp") for pos = 1, 2 does not work (could not determine data type of parameter).
Using PreparedStatement.setNull(pos, 91) does work!
Is it expected?
Rémi
Le mer. 6 déc. 2017 à 01:58, Dave Cramer <pg@fastcrypt.com> a écrit :
So ps.setNull(1, Types.TIMESTAMP);Doesn't work ?On 5 December 2017 at 15:42, David G. Johnston <david.g.johnston@gmail.com> wrote: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.Not that I am aware.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.I'd probably perform the null test in Java and pass the true/false boolean result along to the query:SELECT * FROM my_table WHERE ?::bool;ps.setBoolean(1, tsvar = null); //my Java is rusty but you get the idea.That should work in any database.David J.
В списке pgsql-jdbc по дате отправления: