X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A520B5280E for ; Tue, 17 May 2005 02:12:19 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 61288-05 for ; Tue, 17 May 2005 05:12:08 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id D703452801 for ; Tue, 17 May 2005 02:12:07 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.13.1/8.13.1) with ESMTP id j4H5C7pU074340 for ; Tue, 17 May 2005 05:12:07 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.13.1/8.13.1/Submit) id j4H51Hm6070693 for pgsql-sql@postgresql.org; Tue, 17 May 2005 05:01:17 GMT (envelope-from news) From: Ezequiel Tolnay X-Newsgroups: pgsql.sql Subject: Re: getting duplicate number is there a Date: Tue, 17 May 2005 15:02:17 +1000 Organization: Hub.Org Networking Services Lines: 31 Message-ID: References: <000e01c55a5f$4d912d00$797ba8c0@jfradkin> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050319 X-Accept-Language: en-au, en-gb, en-us, en, es-ar, es-es In-Reply-To: <000e01c55a5f$4d912d00$797ba8c0@jfradkin> To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200505/125 X-Sequence-Number: 21438 You can select "for update", so you ensure that the rows are locked for your current transaction's use exclusively. If the rows in question had been modified by another ongoing transaction, then the select will get blocked until the other transaction is finished. Cheers, Ezequiel Tolnay etolnay@gbtech.com.au Joel Fradkin wrote: > I was using SET TRANSACTION ISOLATION LEVEL SERIALIZABLE in MSSQL. > > Is there something similar in postgres to ensure its not in the middle > of being updated? > > sql = "SELECT COUNT(*) FROM tblcase WHERE LocationID = " & > intLocationID & _ > > " and substr(casenum,length(casenum)-1,2) = '" & > right(year(date),2) & "' AND clientnum = '" & _ > > chrClientNum & "'" > > I will add a select just before doing the insert to see if this helps, > its not happening a bunch, but 5 6 times a day is still an issue for me. > > I use the count as a segment of my case number so each time a new case > is entered the count goes up for that location for that year. > > Joel Fradkin