X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 1B5D59DCAA6 for ; Thu, 23 Feb 2006 12:34:36 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01366-09 for ; Thu, 23 Feb 2006 12:34:34 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from peufeu.com (unknown [82.67.9.10]) by postgresql.org (Postfix) with ESMTP id A42059DCA86 for ; Thu, 23 Feb 2006 12:34:32 -0400 (AST) Received: (qmail 22966 invoked from network); 23 Feb 2006 17:35:22 +0100 Received: from unknown (HELO apollo13) (82.67.9.10) by boutiquenumerique.com with SMTP; 23 Feb 2006 17:35:22 +0100 Date: Thu, 23 Feb 2006 17:35:21 +0100 To: mario.splivalo@mobart.hr, "Achilleus Mantzios" Subject: Re: 'locking' the SELECTs based on indices... Cc: pgsql-sql@postgresql.org References: <1140692542.5002.26.camel@localhost.localdomain> From: PFC Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: In-Reply-To: <1140692542.5002.26.camel@localhost.localdomain> User-Agent: Opera M2/8.51 (Linux, build 1462) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.103 required=5 tests=[AWL=0.103] X-Spam-Score: 0.103 X-Spam-Level: X-Archive-Number: 200602/280 X-Sequence-Number: 24290 > Now, If some other user want's his prize, when checking his code, if he > sends code for some other service then service 1, that's ok. If he's > sends code for the service 1 the PERFORM will wait untill I'm finished > with previous user. Sorry for the double post. If the rows in your table represent associations between codes and services that are one-use only, you could simply use UPDATE or DELETE, to mark the row in question as having been "consumed". Then, you check how many rows were deleted or updated. If it's 1, good. If it's 0, the code has been used already. If the code itself is one-use only, you should have a codes table and a codes_to_services table, with an ON DELETE CASCADE so that, when you use a code, you delete it from the codes table and it's "consumed" for all services.