X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 85C039FA326 for ; Thu, 18 May 2006 19:22:15 -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 08180-02 for ; Thu, 18 May 2006 19:22:07 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail63.csoft.net (mail63.csoft.net [205.205.214.4]) by postgresql.org (Postfix) with SMTP id A22309FA1B0 for ; Thu, 18 May 2006 19:22:07 -0300 (ADT) Received: (qmail 21624 invoked by uid 1112); 18 May 2006 22:21:56 -0000 Date: Thu, 18 May 2006 17:21:56 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary2.csoft.net To: Alexandre de Arruda Paes cc: pgsql-jdbc@postgresql.org Subject: Re: Automatic cast In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/82 X-Sequence-Number: 15210 On Thu, 18 May 2006, Alexandre de Arruda Paes wrote: > I have a problem and I want know if this can be solved in the jdbc driver. > Our company develop softwares using a CASE Tool caled Genexus. The > SQL sintaxe are not changeable and they have a big problem: the querys > aren't casted. > > SELECT field from table where field=10 > > If the field are int2 or int8, PostgreSQL don't use indexes (its > converts the value 10 to int4). This should work fine in 8.0 and up when cross type index access was added. If you're not using 8.0+ consider an upgrade. If you are using 8.0+ please provide more details about your problem. > Can I put an implicit (automatic) cast (' ' - apostrofes) in the SQL > sintaxes passed throught JDBC ??? You can write: SELECT field FROM table WHERE field = ?::int8 or SELECT field FROM table WHERE field = CAST(? AS int8); Kris Jurka