Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id E24922E37F3 for ; Wed, 19 Dec 2007 11:48:57 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 10599-03-3 for ; Wed, 19 Dec 2007 11:48:53 -0400 (AST) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 461252E37F6 for ; Wed, 19 Dec 2007 11:48:53 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id lBJFmjPX023205; Wed, 19 Dec 2007 10:48:45 -0500 (EST) To: "Matt Magoffin" cc: pgsql-jdbc@postgresql.org Subject: Re: setting PreparedStatement parameter using "at time zone interval ?" In-reply-to: <55255.192.168.1.108.1198055905.squirrel@msqr.us> References: <55255.192.168.1.108.1198055905.squirrel@msqr.us> Comments: In-reply-to "Matt Magoffin" message dated "Wed, 19 Dec 2007 22:18:25 +1300" Date: Wed, 19 Dec 2007 10:48:45 -0500 Message-ID: <23204.1198079325@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/150 X-Sequence-Number: 18005 "Matt Magoffin" writes: > I'm using the latest 8.3 development driver against an 8.3 database. I > thought back in 8.1 I used to be able to use a PreparedStatement that > included something like > ... date(l.created AT TIME ZONE INTERVAL ?) That might've worked back before the driver did real prepared statements. It's invalid syntax though, because typename before the constant works only for simple literal string constants. You got away with it when the driver interpolated parameter values into the query as string literals, but you can't do it anymore. ?::interval (or the full-blown CAST syntax) is the right way. See http://developer.postgresql.org/pgdocs/postgres/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS particularly 4.1.2.5. regards, tom lane