Error Could Not Determine Data Type Of Parameter $1
Contents |
here for a quick overview of the site Help
Query Failed Error Could Not Determine Data Type Of Parameter $1
Center Detailed answers to any questions you might have could not determine data type of parameter $3 Meta Discuss the workings and policies of this site About Us Learn more about Stack postgres types Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up could not determine data type of parameter $1, while executing COPY..TO statement up vote 2 down vote favorite I want to write the content of a table from the database into CSV file using JDBC prepared statement. The PSQL query that I am using is: COPY(select * from file where uploaded_at > ?) TO '/tmp/file_info.csv' With DELIMITER ',' CSV HEADER "; My code is as follows: private void copyData(Connection conn, Date date){ String sql = "COPY (select * from file where uploaded_at< ?) TO '/tmp/file_info.csv' With DELIMITER ',' CSV HEADER "; PreparedStatement stmt = conn.prepareStatement(sql); stmt.setTimestamp(1, new Timestamp(date.getTime())); stmt.execute(); } I get the following stack when I run this query: org.postgresql.util.PSQLException: ERROR: could not determine data type of parameter $1 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:381) at tests.com.paramatrix.pace.archival.file.TestFileArchival.main(TestFileArchival.java:63) This exception is not generated while running a simple select query like: select * from file where uploaded_at > ? Wha
Regional lists Associations User groups Project lists pgadmin-hackers pgadmin-support pgsql-jdbc pgsql-odbc pgsql-pkg-debian pgsql-pkg-yum psycopg Inactive lists IRC Local User Groups Featured Users International Sites Propaganda Resources Weekly News Re: Could not determine data type of parameter $1 From: Tom Lane
Community Contact Login/Register Download Now ProductsAnswersExchangeDocsWikiPlanetTracker You are hereHome » Answers » PostgreSQL timestamp parameter: could not determine data type of parameter $1 http://community.jaspersoft.com/questions/969681/postgresql-timestamp-parameter-could-not-determine-data-type-parameter-1 PostgreSQL timestamp parameter: could not determine data type of parameter $1 Posted on December 30, 2015 at 7:11pm 0 I'm really struggling to get my query to work against my PostgreSQL database. Essentially, my query can be delimited by a timestamp, a parameter that the user can input, but which can could not also be empty. If no timestamp is provided, I must tell PostgreSQL to use '-infinity' instead. I tried writing the conditional statement below, but I get the error 'Could not determine data type of parameter $1' Can anyone tell me what's wrong with my query? SELECT * FROM log WHERE CASE could not determine WHEN $P{timestampFrom} IS NULL THEN TIMESTAMP >= '-infinity' ELSE TIMESTAMP >= $P{timestampFrom} END $P{timestampFrom} is a sql.Timestamp parameter. Jaspersoft Studio jean.sebastien.lemay 30 Joined: Dec 30 2015 - 7:02pm Last seen: 9 months 2 weeks ago 1 Answer: 1 Posted on December 30, 2015 at 7:19pm OK, I realised it was a PostgreSQL error. The solution is to force PostgreSQL to interpret the parameter as a timestamp SELECT * FROM log WHERE CASE WHEN $P{timestampFrom}::TIMESTAMP IS NULL THEN TIMESTAMP >= '-infinity' ELSE TIMESTAMP >= $P{timestampFrom} END jean.sebastien.lemay 30 Joined: Dec 30 2015 - 7:02pm Last seen: 9 months 2 weeks ago Subscribe Similar Questions Related Documentation Tags PostgreSQLTimestampsDatatype Copyright © 2016 TIBCO Software, Inc.All rights reserved. Answers Exchange Documentation Wiki Tracker Privacy Policy User Groups Contribute to our Wiki Request a Feature Report a Bug Share your Extension Terms of Use JasperReports Server JasperReports Library Jaspersoft ETL Jaspersoft Studio Visualize.js Contact Us randomness