X-Original-To: pgsql-jdbc-postgresql.org@postgresql.org Received: from localhost (unknown [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 79D799FB2FA for ; Wed, 30 Aug 2006 10:07:50 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 26897-05-2 for ; Wed, 30 Aug 2006 10:07:30 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 6FAAF9FB2F0 for ; Wed, 30 Aug 2006 10:05:48 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k7UD5goG026410; Wed, 30 Aug 2006 09:05:42 -0400 (EDT) To: Kris Jurka cc: Vincent Risi , pgsql-jdbc@postgresql.org Subject: Re: Could not determine data type of parameter $1 In-reply-to: References: <44EEB4F4.2050202@bbd.co.za> Comments: In-reply-to Kris Jurka message dated "Tue, 29 Aug 2006 21:56:28 -0500" Date: Wed, 30 Aug 2006 09:05:42 -0400 Message-ID: <26409.1156943142@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.135 tagged_above=0 required=5 tests=AWL, SPF_HELO_PASS, SPF_PASS X-Spam-Level: X-Archive-Number: 200608/176 X-Sequence-Number: 15703 Kris Jurka writes: > When given a timestamp parameter the jdbc driver does not know if it is > going to be used a timestamp with time zone or a timestamp without time > zone. The driver passes it to the server as an unknown data type letting > the server figure out what to do with it. Usually you'll have > timestampcol = ? or you're inserting into a timestamp field so the server > can easily determine the true datatype the parameter is being used at. In > this case since it's just being sent back to the user the server cannot > determine the type and bails out. You need to help it along with a cast: > "SELECT ?::timestamptz". Hm, I wonder if we are being overly strict about this. In the non-prepared-statement scenario, you can do SELECT 'foo' and the system just plays dumb and emits the string again --- it's perfectly happy to report the datatype as UNKNOWN. Is it reasonable to allow the same treatment for parameter symbols, or will client code just choke anyway if it sees the parameter type come back as UNKNOWN? regards, tom lane