Take the 2-minute tour ×

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 :(

share|improve this question
I can now narrow it down. The problem only reproduces when the SQL is in this form: select * from baa where start_date <= ? - 30 and does not reproduce when you remove the "- 30". My guess: when you specify the - 30, Netezza is trying to parse the bind variable as something other than date. –  ihadanny Jan 23 '11 at 12:08
add comment

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
add comment

Your Answer


