From: btober@seaworthysys.com
To: rbt@rbt.ca
Cc: pgsql-sql@postgresql.org
Subject: Re: Does a the block of code within a stored procedure constitute a transaction?
Date: Thu, 31 Jul 2003 21:28:18 -0400 (EDT)
Message-ID: <65027.66.212.203.144.1059701298.squirrel@$HOSTNAME> (raw)
In-Reply-To: <1059698237.33557.8.camel@jester>
References: <64821.216.238.112.88.1059509762.squirrel@$HOSTNAME>
<1059698237.33557.8.camel@jester>
>> 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?
>>
>> 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.
Yes, and I like the fact that the UPDATE first approach eliminates a
local variable declaration as well!
~Berend Tober
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: btober@seaworthysys.com, rbt@rbt.ca
Subject: Re: Does a the block of code within a stored procedure constitute a transaction?
In-Reply-To: <65027.66.212.203.144.1059701298.squirrel@$HOSTNAME>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox