Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 884052E004D for ; Wed, 11 Jun 2008 13:59:51 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 92568-10 for ; Wed, 11 Jun 2008 13:59:29 -0300 (ADT) X-Greylist: delayed 00:29:04.669674 by SQLgrey-1.7.6 Received: from iserver.abag.ca.gov (iserver.abag.ca.gov [198.31.87.3]) by developer.postgresql.org (Postfix) with ESMTP id C831C2E0064 for ; Wed, 11 Jun 2008 13:58:19 -0300 (ADT) Received: from groupwise.abag.ca.gov (groupwise.abag.ca.gov [198.31.87.26]) by iserver.abag.ca.gov (8.14.2/8.14.2) with ESMTP id m5BGTAgN024466 for ; Wed, 11 Jun 2008 09:29:11 -0700 (PDT) Received: from D01-MTA by groupwise.abag.ca.gov with Novell_GroupWise; Wed, 11 Jun 2008 09:29:10 -0700 Message-Id: <484F9AD7020000A700007E91@groupwise.abag.ca.gov> X-Mailer: Novell GroupWise Internet Agent 7.0.1 Date: Wed, 11 Jun 2008 09:28:55 -0700 From: "Fred Parkinson" To: , Subject: Re: wrong value returned? References: <6unltd$18tre9@toip37-bus.srvr.bell.ca> In-Reply-To: <6unltd$18tre9@toip37-bus.srvr.bell.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200806/15 X-Sequence-Number: 9545 This doesn't explain the error, but solves the problem for me: use a query = like SELECT Max(registration_id) AS MaxID FROM registrations; Another solution, if you are using a sequenced serial value, is to use the = 'last_value' function on the sequencing table: select registration_registration__seq.last_value from registration_registr= ation__seq; >>> 06/11/2008 7:04 AM >>> Hi, I've setup a query in my program to get the biggest value used in my = "customers" table. There is a serial column called customer_id. I use = the following query within my program and it returns, lets say, 3. If I = run the same query from the psql console window (over and over and at the = same point where I've stepped to in my program), it will consistently = return 2 whereas the program will consistently return 3 (always one more). Here is the query to get the last ID used: SELECT customer_id from customers order by customer_id DESC limit 1; I do one fetch and have my result programmatically which is always 1 more = than the value returned by the psql console window method. What gives? Many thanks, Mike --=20 Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc=20