Hi:
postgres: 9.3.4
driver: postgresql-9.3-1102.jdbc4.jar
I have the following query:
select
count(*) from checkin
where
pid = ? and checkin_time > current_date - interval '? days'
When I try to set the interval (parameter 2, second question mark):
ps.setLong("pid", 123);
ps.setInt("interval_days", 7);
I get the following error:
ERROR org.postgresql.util.PSQLException: The column index is out of
range: 2, number of columns: 1
at
org.postgresql.core.v3.SimpleParameterList.bind(SimpleParameterList.java:56)
=====
I looked at the mailing list archives and whereas others have seen the
same issue, I am trying to understand the root cause of why the JDBC
driver throws an error here ? Should it just set the location of the
second question mark, with the specified data type (in this case in
integer) ? What's the point of throwing an error, why does the
preparedstatement care ? Its job is to simply replace question marks
with the specified data type, right ?
Best
--j
`