X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id DB6A9D1C96F for ; Fri, 1 Aug 2003 00:36:31 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 97897-07 for ; Thu, 31 Jul 2003 21:35:27 -0300 (ADT) Received: from mailav.tor1.inquent.com (mail.inquent.com [216.208.117.106]) by svr1.postgresql.org (Postfix) with ESMTP id 2758ED1C958 for ; Thu, 31 Jul 2003 21:36:31 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mailav.tor1.inquent.com (Postfix) with ESMTP id 1B49510248; Thu, 31 Jul 2003 20:29:18 -0400 (EDT) Received: from [192.168.1.200] (dyn-133-81.tor.dsl.tht.net [134.22.133.81]) by mailav.tor1.inquent.com (Postfix) with ESMTP id 9461D1024D; Thu, 31 Jul 2003 20:29:15 -0400 (EDT) Subject: Re: Does a the block of code within a stored procedure constitute From: Rod Taylor To: btober@seaworthysys.com Cc: pgsql-sql@postgresql.org In-Reply-To: <64821.216.238.112.88.1059509762.squirrel@$HOSTNAME> References: <64821.216.238.112.88.1059509762.squirrel@$HOSTNAME> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-9KjNCplItEwgzu9CdEHZ" Message-Id: <1059698237.33557.8.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.3 Date: 31 Jul 2003 20:37:18 -0400 X-Virus-Scanned: by AMaViS perl-11 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/498 X-Sequence-Number: 14612 --=-9KjNCplItEwgzu9CdEHZ Content-Type: text/plain Content-Transfer-Encoding: quoted-printable > What I need to know is whether or not this is multi-user safe, i.e., will > the block of code in the procedure execute as a transaction so that if > more than one clerk creates an expense report for the same employee > simultaneously is it possible or impossible that value of the > employee.expense_report_seq gets updated by the second clerk between the > SELECT and UPDATE statements invoked by the first clerk? >=20 > And as a follow-up, should I add the FOR UPDATE clause to the SELECT > statement? SELECT .. FOR UPDATE would be appropriate. However, you could also do an update + 1 first and the select second to find what you changed the value to. --=-9KjNCplItEwgzu9CdEHZ Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (FreeBSD) iD8DBQA/KbY96DETLow6vwwRApM5AJ0af+9Qw/4nJHJT+kNttceXAGAClACdEo2X +v96Fi3/3lSfDptXrO88Fcg= =UCCp -----END PGP SIGNATURE----- --=-9KjNCplItEwgzu9CdEHZ--