pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rod Taylor <rbt@rbt.ca>
To: btober@seaworthysys.com
Cc: pgsql-sql@postgresql.org
Subject: Re: Does a the block of code within a stored procedure constitute
Date: 31 Jul 2003 20:37:18 -0400
Message-ID: <1059698237.33557.8.camel@jester> (raw)
In-Reply-To: <64821.216.238.112.88.1059509762.squirrel@$HOSTNAME>
References: <64821.216.238.112.88.1059509762.squirrel@$HOSTNAME>

> 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.

Attachments:

  signature.asc (application/pgp-signature, 186B) download

view thread (3+ messages)  latest in thread

Message-ID: <1059698237.33557.8.camel@jester>
Permalink:  ../1059698237.33557.8.camel@jester/
Also on:    postgresql.org/message-id/1059698237.33557.8.camel@jester

 · 

reply

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: rbt@rbt.ca, btober@seaworthysys.com
  Subject: Re: Does a the block of code within a stored procedure constitute
  In-Reply-To: <1059698237.33557.8.camel@jester>

* 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