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 8BBFF5374F for ; Wed, 4 May 2005 11:14:21 -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 63265-06 for ; Wed, 4 May 2005 14:14:19 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id A0DED534BF for ; Wed, 4 May 2005 11:14:18 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j44EEJ2V017997; Wed, 4 May 2005 10:14:20 -0400 (EDT) To: Guillaume Cottenceau Cc: pgsql-jdbc@postgresql.org Subject: Re: postgresql-8.0.jar and failure of ORDER BY parameters In-reply-to: <874qdjpfe5.fsf@meuh.mnc.ch> References: <874qdjpfe5.fsf@meuh.mnc.ch> Comments: In-reply-to Guillaume Cottenceau message dated "04 May 2005 10:24:50 +0200" Date: Wed, 04 May 2005 10:14:19 -0400 Message-ID: <17996.1115216059@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/16 X-Sequence-Number: 12847 Guillaume Cottenceau writes: > SELECT .... ORDER BY ?, ? > actionSt.setInt( 1, 4 ); > actionSt.setInt( 2, 5 ); This would appear to be asking for a sort by two constant values, which of course is not going to order the data usefully at all --- all the rows will have the same sort keys. I suppose that it behaved differently in older versions of the JDBC driver that didn't implement real server-side prepared statements. If the parameters are substituted textually before the server sees the command, then you have "ORDER BY 4,5" which is interpreted according to the old SQL92 syntax --- ie, sort by fourth and fifth columns of the output. But anything beyond a simple integer literal --- in particular, a parameter symbol --- is treated as an expression value per SQL99. So no, you can't do it like that. The fact that it happened to "work" before was an artifact of the implementation. regards, tom lane