pgsql: cannot use extract function inside a where clause

For Exmple:


AND (date_part('YEAR',fin_finacc_transaction.statementdate) = $P{Año})


AND ((extract(Year from  fin_finacc_transaction.statementdate) LIKE $P{Año}) OR $P{Año} = 'ALL')

Neither of these work, I guess it has something to do with the Parameter type, as it works when I use a number instead of the Parameter.

See error Log.

net.sf.jasperreports.engine.JRException: Error executing SQL statement for : Cuenta de Banco
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(
at org.eclipse.jface.operation.ModalContext$
Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: double precision = character varying
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
Position: 1419
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(
at org.postgresql.core.v3.QueryExecutorImpl.processResults(
at org.postgresql.core.v3.QueryExecutorImpl.execute(
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(
... 5 more

Leave a Reply

Your email address will not be published. Required fields are marked *