X-Original-To: pgsql-general@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7214A4761DD for ; Fri, 28 Feb 2003 17:06:54 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 41513-02 for ; Fri, 28 Feb 2003 17:06:43 -0500 (EST) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 99954475E4A for ; Fri, 28 Feb 2003 15:48:32 -0500 (EST) Received: by news.hub.org (Postfix, from userid 8) id 7D8B043A94A; Fri, 28 Feb 2003 15:48:32 -0500 (EST) From: Dmitry Tkach X-Newsgroups: comp.databases.postgresql.general, comp.databases.postgresql.questions Subject: Re: Locking rows Date: Fri, 28 Feb 2003 17:25:58 -0500 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 31 Message-ID: <3E5FE1F6.7060504@openratings.com> References: <3E5F931D.6090509@mega-bucks.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org To: Jean-Christian Imbeault User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en In-Reply-To: <3E5F931D.6090509@mega-bucks.co.jp> To: pgsql-general@postgresql.org X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/1722 X-Sequence-Number: 38476 Jean-Christian Imbeault wrote: > Doug McNaught wrote: > >>If you use a single query to generate the rows, this will not be a >>problem. >> >>If you use multiple queries, execute them all inside a transaction and >>you will get a consistent view of the database. >> >>No locking needed. > > > True but what I am worried about is the data changing while I am in a > transaction. > > Right now I want to print customer receipts for items that have been > ordered. But while I gathering the data, which takes more than one > query, a customer might come along and cancel an invoice. > > In that case I would print a receipt for something that was cancelled. > > I need to find a way to avoid this. I thought locking was a way around > this ... or maybe I need to change my "business" logic or the way the > app gathers the data? > But can't the customer cancel that invoice one millisecond *after* your application is done? As far as I can see, from the customer's standpoint, it will look exactly the same, won't it? Dima