Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 0A52F2E0063 for ; Wed, 11 Jun 2008 11:05:10 -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 17872-04 for ; Wed, 11 Jun 2008 11:04:47 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from tomts52-srv.bellnexxia.net (tomts52.bellnexxia.net [209.226.175.177]) by developer.postgresql.org (Postfix) with ESMTP id 199962E0093 for ; Wed, 11 Jun 2008 11:04:39 -0300 (ADT) Received: from toip37-bus.srvr.bell.ca ([67.69.240.38]) by tomts52-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20080611140422.NSFH1589.tomts52-srv.bellnexxia.net@toip37-bus.srvr.bell.ca> for ; Wed, 11 Jun 2008 10:04:22 -0400 Message-Id: <6unltd$18tre9@toip37-bus.srvr.bell.ca> X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgpbAGJ1T0jR4q+G/2dsb2JhbACKEQGHAJp0gRg Received: from tofep2.bellnexxia.net (HELO smtp.bellnexxia.net) ([209.226.175.134]) by toip37-bus.srvr.bell.ca with SMTP; 11 Jun 2008 10:04:22 -0400 X-Mailer: Openwave WebEngine, version 2.8.11 (webedge20-101-194-20030622) X-Originating-IP: [198.168.152.20] From: To: Subject: wrong value returned? Date: Wed, 11 Jun 2008 10:04:22 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.495 tagged_above=0 required=5 tests=MSGID_FROM_MTA_HEADER=1.495 X-Spam-Level: * X-Archive-Number: 200806/14 X-Sequence-Number: 9544 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