Received: from news.tht.net (news.hub.org [216.126.91.242]) by hub.org (8.10.1/8.10.1) with ESMTP id e5E5gHT99414 for ; Wed, 14 Jun 2000 01:42:17 -0400 (EDT) Received: (from news@localhost) by news.tht.net (8.9.3/8.9.3) id BAA51143 for pgsql-sql@postgresql.org; Wed, 14 Jun 2000 01:41:54 -0400 (EDT) (envelope-from news) X-Authentication-Warning: news.tht.net: news set sender to using -f From: Peter Dixon X-Newsgroups: linux.postgres, comp.databases.postgresql.questions, comp.databases.postgresql.sql Subject: Re: Simple search question Date: 13 Jun 2000 12:25:09 +0100 Organization: GXSN Lines: 39 Message-ID: <87hfaxkelm.fsf@ptdixon.globalnet.co.uk> References: <39457549.CEA07C63@ihug.com.au> <39459935.CCCEFDAA@ihug.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: 960960999 1NNUCNF1G9305C393C gxsn.com X-Complaints-To: abuse@gxsn.com User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.3 To: pgsql-sql@postgresql.org X-Archive-Number: 200006/148 Alex writes: > Hi, > after running a script which performs an insert, a new tuple is > created, and a serial number is generated for it. I want to write the > new tuple data back to the screen, including the new serial number. > My question is, do I have to do a search for the tuple just inserted in > order to get the data back again? I am thinking there must be a faster, > more efficient way. > Thanks, > Alex I had the same problem but was using Java, not PHP (I guess that whatever I can do in JDBC, you can do in PHP ;-)). SELECT last_value FROM ; worked fine to retrieve the last-used serial number. I could have used SELECT i.* FROM i, s WHERE i.serial=s.last_value; to retrieve the tuple, but I didn't need to do this. > This leads to another question. If someone adds another row during this, > what will happen? In JDBC I would turn off auto-commit mode, then commit after the SELECT. This should ensure that the sequence doesn't get incremented between INSERT and SELECT. > > Thanks, > Alex Hope this helps, Peter