Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fB7GB-00084O-Dn for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Apr 2018 23:22:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fB7G9-0004K6-T5 for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Apr 2018 23:22:05 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fB7G9-0004Jx-Jq for pgsql-bugs@lists.postgresql.org; Tue, 24 Apr 2018 23:22:05 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fB7G7-0001hz-4J for pgsql-bugs@lists.postgresql.org; Tue, 24 Apr 2018 23:22:04 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w3ONM1bM017553; Tue, 24 Apr 2018 19:22:02 -0400 From: Tom Lane To: len.carlsen@ubc.ca cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15171: JDBC TIMESTAMP WITH TIME ZONE PSQLException When Using Substitution Parameter In-reply-to: <152459274229.19802.17031385353863581472@wrigleys.postgresql.org> References: <152459274229.19802.17031385353863581472@wrigleys.postgresql.org> Comments: In-reply-to =?utf-8?q?PG_Bug_reporting_form?= message dated "Tue, 24 Apr 2018 17:59:02 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <17551.1524612121.1@sss.pgh.pa.us> Date: Tue, 24 Apr 2018 19:22:01 -0400 Message-ID: <17552.1524612121@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?utf-8?q?PG_Bug_reporting_form?= writes: > Executing this query works fine: 'SELECT TIMESTAMP WITH TIME ZONE > '2018-04-17 12:00:00.0-07'" > But executing query "SELECT TIMESTAMP WITH TIME ZONE ?" with a substitution > parameter results in a PSQLException syntax error. Yes. A parameter symbol is not a syntactic equivalent to a string literal; it's more nearly like a variable. You can't say "typename variable" either. You need to write it like a cast, ie "variable::typename", or "CAST(variable AS typename)" if you want to be pedantically standards-compliant. So what you want is "SELECT ?::TIMESTAMP WITH TIME ZONE". (Allowing the non-orthogonal, non-extensible syntax "typename string-literal" was not one of the SQL committee's better decisions IMV. We're stuck with supporting it, but I'd suggest avoiding it in favor of cast-like notation, which works in a much wider variety of cases.) regards, tom lane