Received: from digital-mission.com (IDENT:root@ip-050.digipath.net [208.205.224.50] (may be forged)) by hub.org (8.10.1/8.10.1) with ESMTP id e873FgB47450 for ; Wed, 6 Sep 2000 23:15:42 -0400 (EDT) Received: from digital-mission.com (IDENT:mdz@roebling.phalanx.net [208.205.224.170]) by digital-mission.com (8.9.3/8.9.3) with ESMTP id XAA20963 for ; Wed, 6 Sep 2000 23:25:00 -0400 Message-ID: <39B70836.94523C33@digital-mission.com> Date: Wed, 06 Sep 2000 23:15:02 -0400 From: Mark Dzmura Organization: Digital Mission LLC X-Mailer: Mozilla 4.73 [en] (X11; U; Linux 2.2.14-5.0 i686) X-Accept-Language: en MIME-Version: 1.0 To: "pgsql-interfaces@postgreSQL.org" Subject: obtaining primary key/rowid following insert, redux... Content-Type: multipart/mixed; boundary="------------0B0D7350074EB6152FEF52DF" X-Archive-Number: 200009/26 This is a multi-part message in MIME format. --------------0B0D7350074EB6152FEF52DF Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Peter: Trying to solve my problem mentioned in the email of half an hour ago, I searched through the archives of the interface list and found some of your replies suggesting using "currval()" to get the last value assigned from a sequence... However, here's what happens in a good database with multiple in-use sequences: db=# select currval('foo_foo_id_seq'); ERROR: foo_foo_id_seq.currval is not yet defined in this session As an alternative, I discovered that I can get the value this way: db=# select last_value from foo_foo_id_seq; last_value --------- 27 My questions are, (1) why does the currval() approach give the error message, and (2) is it OK to use my alternative?? Finally, as far as I can tell, there is a real race condition problem here in a multiple-connection scenario (e.g. another task can cause the sequence to be incremented between the insert and the select) - but wrapping a transaction around the insert and select should take care of it... Thoughts?? Thanks, Mark Dzmura --------------0B0D7350074EB6152FEF52DF Content-Type: text/x-vcard; charset=us-ascii; name="mdz.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Mark Dzmura Content-Disposition: attachment; filename="mdz.vcf" begin:vcard n:Dzmura;Mark tel;fax:412-429-3361 tel;work:412-429-6001 x-mozilla-html:FALSE org:Digital Mission, LLC adr:;;230 E. Main St., Suite 210;Carnegie;PA;15106;USA version:2.1 email;internet:mdz@digital-mission.com title:President x-mozilla-cpt:;0 fn:Mark Dzmura end:vcard --------------0B0D7350074EB6152FEF52DF--