X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1B9AED1B169 for ; Thu, 17 Jun 2004 19:26:01 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 36482-09 for ; Thu, 17 Jun 2004 22:26:00 +0000 (GMT) Received: from mail63.csoft.net (unknown [63.111.22.74]) by svr1.postgresql.org (Postfix) with SMTP id 7541BD1B18C for ; Thu, 17 Jun 2004 19:25:53 -0300 (ADT) Received: (qmail 23897 invoked by uid 1112); 17 Jun 2004 22:25:54 -0000 Date: Thu, 17 Jun 2004 17:25:54 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Jie Liang Cc: Tom Lane , pgsql-sql@postgresql.org, pgsql-jdbc@postgresql.org Subject: Re: Prepare Statement In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/81 X-Sequence-Number: 10283 On Thu, 17 Jun 2004, Jie Liang wrote: > Kris, > You are right, I modified that piece of code a little bit, > CallableStatement stmt = conn.prepareCall("{?=call chr(?)}"); > Then my log file were: > Select * from chr(65) as result; > Select * from chr(66) as result; > ...... > However, if I use: > PrepareStatement stmt = conn.prepareStatement("SELECT chr(?)"); > Then my log file are same as yours.i.e. it use PREPARE and EXECUTE. > > So, I am getting confusion. > I think CallableStatement is extended from PrepareStatement, it should > have same behaviou. > What's happening here is that you can only use prepared statements for certain operations. You can't for example prepare a CREATE TABLE statement. The driver examines the query to see if it is valid for preparing and I believe the problem here is that with a callable statement it is examinging the query with "call" before it is transformed to a SELECT, so it doesn't recognize it as a preparable. This looks like a bug to me. Kris Jurka