Question

When passing a Java.Sql.Date as a bind variable (a question mark in my query text) in a PreparedStatement to nzjdbc.jar, I'm getting:

pg_atoi: error in "2010-02-01": can't parse "-02-01"

what gives? I thought that the whole purpose of a JDBC driver is to fix such issues :(

Was it helpful?

Solution

Ok, found the answer, not related to JDBC.

When passing a date variable to JDBC, all it does is translate it to a literal string fitting the Netezza dateStyle, e.g. '2011-11-06 00:00:00'. It does not wrap it with a cast or to_date or anything.

However, when you try select '2011-11-06 00:00:00' - 30 from any Netezza client, you get a pg-atoi parse error, as Netezza tries to parse the string as a number, not as a date.

Solution: select cast('2004-02-22 00:00:00.000' as date) - 30 as bla;

its all cosmic love baby.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top